Avoid unnecessary allocation of temporaries in layout line cache

This commit is contained in:
Jonathan G Rennison
2024-05-30 19:14:01 +01:00
parent 99e6b75337
commit c6c7191b16
2 changed files with 2 additions and 2 deletions

View File

@@ -389,7 +389,7 @@ Layouter::LineCacheItem &Layouter::GetCachedParagraphLayout(std::string_view str
LineCacheKey key;
key.state_before = state;
key.str.assign(str);
return (*linecache)[key];
return (*linecache)[std::move(key)];
}
/**

View File

@@ -138,7 +138,7 @@ class Layouter : public std::vector<std::unique_ptr<const ParagraphLayouter::Lin
};
struct LineCacheQuery {
FontState state_before; ///< Font state at the beginning of the line.
const FontState &state_before; ///< Font state at the beginning of the line.
std::string_view str; ///< Source string of the line (including colour and font size codes).
};