Codechange: Cache layouted text for the last used width. (#14177)

This commit is contained in:
Peter Nelson
2025-05-03 18:33:47 +01:00
committed by GitHub
parent bd1a3fe0b7
commit 7596f98e2d
2 changed files with 19 additions and 6 deletions

View File

@@ -135,7 +135,7 @@ public:
*
* It also accounts for the memory allocations and frees.
*/
class Layouter : public std::vector<std::unique_ptr<const ParagraphLayouter::Line>> {
class Layouter : public std::vector<const ParagraphLayouter::Line *> {
std::string_view string; ///< Pointer to the original string.
/** Key into the linecache */
@@ -174,6 +174,9 @@ public:
FontState state_after; ///< Font state after the line.
std::unique_ptr<ParagraphLayouter> layout = nullptr; ///< Layout of the line.
std::vector<std::unique_ptr<const ParagraphLayouter::Line>> cached_layout{}; ///< Cached results of line layouting.
int cached_width = 0; ///< Width used for the cached layout.
};
private:
typedef std::map<LineCacheKey, LineCacheItem, LineCacheCompare> LineCache;