mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
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:
parent
731c56d116
commit
b56775f576
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user