Closed Bug 1850505 Opened 1 years ago Closed 1 years ago

Avoid -ftrivial-auto-var-init overhead in mozHunspellFileMgrHost::GetLine

Categories

(Firefox Build System :: General, task)

task

Tracking

(firefox119 fixed)

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: sergesanspaille, Assigned: sergesanspaille)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

mozHunspellFileMgrHost::GetLine is defined as followed:

 bool mozHunspellFileMgrHost::GetLine(std::string& aResult) {
  nsAutoCString line;
  auto res = ReadLine(line);
  if (res.isErr()) {
    return false;
  }

  aResult.assign(line.BeginReading(), line.Length());
  return true;
}

nsAutoCString iteracts poorly with -ftrivial-auto-var-init as it always initializes the internal buffer. In that particular case line is used a temporary container, we could avoid both the initialization and the copy by directly writing to a std::string

This also positively impacts -ftrivial-auto-var-init as it gets rid of
the nsAutoCString buffer initialization.

Attachment #9350636 - Attachment description: Bug 1850505 - Avoid extra copy in mozHunspellFileMgrHost::GetLine r=nika → Bug 1850505 - Avoid extra copy in mozHunspellFileMgrHost::GetLine r=emilio
Pushed by sguelton@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cf7a219d11da Avoid extra copy in mozHunspellFileMgrHost::GetLine r=emilio
Status: NEW → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: