Codechange: Avoid making copies of intermediate layout runs. (#12796)

The vector of runs is not used after it is passed to the ParagraphLayout class, so pass with std::move to avoid an unnecessary copy.
This commit is contained in:
Peter Nelson 2024-06-17 22:58:52 +01:00 committed by GitHub
parent 731c56d116
commit b56775f576
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -104,7 +104,7 @@ private:
int partial_offset;
public:
ICUParagraphLayout(std::vector<ICURun> &runs, UChar *buff, size_t buff_length) : runs(runs), buff(buff), buff_length(buff_length)
ICUParagraphLayout(std::vector<ICURun> &&runs, UChar *buff, size_t buff_length) : runs(std::move(runs)), buff(buff), buff_length(buff_length)
{
this->Reflow();
}
@ -374,7 +374,7 @@ std::vector<ICURun> ItemizeStyle(std::vector<ICURun> &runs_current, FontMap &fon
run.Shape(buff, length);
}
return new ICUParagraphLayout(runs, buff, length);
return new ICUParagraphLayout(std::move(runs), buff, length);
}
/* static */ std::unique_ptr<icu::BreakIterator> ICUParagraphLayoutFactory::break_iterator;

View File

@ -113,7 +113,7 @@ public:
}
};
UniscribeParagraphLayout(std::vector<UniscribeRun> &ranges, const UniscribeParagraphLayoutFactory::CharType *buffer) : text_buffer(buffer), ranges(ranges)
UniscribeParagraphLayout(std::vector<UniscribeRun> &&ranges, const UniscribeParagraphLayoutFactory::CharType *buffer) : text_buffer(buffer), ranges(std::move(ranges))
{
this->Reflow();
}
@ -315,7 +315,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
}
}
return new UniscribeParagraphLayout(ranges, buff);
return new UniscribeParagraphLayout(std::move(ranges), buff);
}
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> UniscribeParagraphLayout::NextLine(int max_width)