diff options
author | Michael Lutz <michi@icosahedron.de> | 2019-04-02 21:30:53 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-09 22:45:15 +0200 |
commit | 329bb526134aca214a914f25006c805de78ec851 (patch) | |
tree | 00763488d458fee57ce8ba94e32ae53899367d21 /src/os/macosx | |
parent | 9325d63d8e55758a953f535c5f90534ab9bc01e3 (diff) | |
download | openttd-329bb526134aca214a914f25006c805de78ec851.tar.xz |
Codechange: Store text layout runs directly as values in a std::vector instead of heap allocated.
This reduces memory allocations and heap fragmentation.
Diffstat (limited to 'src/os/macosx')
-rw-r--r-- | src/os/macosx/string_osx.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index f26421e36..55eac42f9 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -53,6 +53,7 @@ public: public: CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff); + CoreTextVisualRun(CoreTextVisualRun &&other) = default; const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; } const float *GetPositions() const override { return &this->positions[0]; } @@ -65,7 +66,7 @@ public: }; /** A single line worth of VisualRuns. */ - class CoreTextLine : public AutoDeleteSmallVector<CoreTextVisualRun *>, public ParagraphLayouter::Line { + class CoreTextLine : public std::vector<CoreTextVisualRun>, public ParagraphLayouter::Line { public: CoreTextLine(CTLineRef line, const FontMap &fontMapping, const CoreTextParagraphLayoutFactory::CharType *buff) { @@ -78,7 +79,7 @@ public: auto map = fontMapping.begin(); while (map < fontMapping.end() - 1 && map->first <= chars.location) map++; - this->push_back(new CoreTextVisualRun(run, map->second, buff)); + this->emplace_back(run, map->second, buff); } CFRelease(line); } @@ -86,7 +87,7 @@ public: int GetLeading() const override; int GetWidth() const override; int CountRuns() const override { return this->size(); } - const VisualRun *GetVisualRun(int run) const override { return this->at(run); } + const VisualRun &GetVisualRun(int run) const override { return this->at(run); } int GetInternalCharLength(WChar c) const override { |