Codechange: Replace AutoDeleteSmallVector with direct std::vector use in text layout code.

This commit is contained in:
Michael Lutz
2019-04-02 21:31:10 +02:00
parent 329bb52613
commit baf9229931
6 changed files with 40 additions and 39 deletions

View File

@@ -111,7 +111,7 @@ public:
this->cur_offset = 0;
}
const Line *NextLine(int max_width) override;
std::unique_ptr<const Line> NextLine(int max_width) override;
};
@@ -188,7 +188,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
return typesetter != NULL ? new CoreTextParagraphLayout(typesetter, buff, length, fontMapping) : NULL;
}
/* virtual */ const CoreTextParagraphLayout::Line *CoreTextParagraphLayout::NextLine(int max_width)
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> CoreTextParagraphLayout::NextLine(int max_width)
{
if (this->cur_offset >= this->length) return NULL;
@@ -200,7 +200,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
CTLineRef line = CTTypesetterCreateLine(this->typesetter, CFRangeMake(this->cur_offset, len));
this->cur_offset += len;
return line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL;
return std::unique_ptr<const Line>(line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL);
}
CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff) : font(font)
@@ -244,8 +244,8 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font
int CoreTextParagraphLayout::CoreTextLine::GetLeading() const
{
int leading = 0;
for (const CoreTextVisualRun * const &run : *this) {
leading = max(leading, run->GetLeading());
for (const auto &run : *this) {
leading = max(leading, run.GetLeading());
}
return leading;
@@ -260,8 +260,8 @@ int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
if (this->size() == 0) return 0;
int total_width = 0;
for (const CoreTextVisualRun * const &run : *this) {
total_width += run->GetAdvance();
for (const auto &run : *this) {
total_width += run.GetAdvance();
}
return total_width;

View File

@@ -134,7 +134,7 @@ public:
this->cur_range_offset = 0;
}
const Line *NextLine(int max_width) override;
std::unique_ptr<const Line> NextLine(int max_width) override;
};
void UniscribeResetScriptCache(FontSize size)
@@ -318,7 +318,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
return new UniscribeParagraphLayout(ranges, buff);
}
/* virtual */ const ParagraphLayouter::Line *UniscribeParagraphLayout::NextLine(int max_width)
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> UniscribeParagraphLayout::NextLine(int max_width)
{
std::vector<UniscribeRun>::iterator start_run = this->cur_range;
std::vector<UniscribeRun>::iterator last_run = this->cur_range;
@@ -404,7 +404,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
if (FAILED(ScriptLayout((int)bidi_level.size(), &bidi_level[0], &vis_to_log[0], NULL))) return NULL;
/* Create line. */
UniscribeLine *line = new UniscribeLine();
std::unique_ptr<UniscribeLine> line(new UniscribeLine());
int cur_pos = 0;
for (std::vector<INT>::iterator l = vis_to_log.begin(); l != vis_to_log.end(); l++) {