diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-03-16 16:28:02 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-03-17 22:49:57 +0100 |
commit | d697e792c5b4b27aad8806694e1b8e22dcc70eae (patch) | |
tree | fb01f0e1107b257dbdb87da9e55bd68bf299195e /include/vcl/glyphitem.hxx | |
parent | 7439cabc643de2f07c18adc35056f802997f484a (diff) |
optimize SalLayoutGlyphs for the common case
This should reduce memory usage (libstdc++ vector is 3 int's and
allocates dynamically). The usual case should be no font fallback.
Change-Id: I2e7981c0962f4f417fd024e3c27f01bc2a71127e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112591
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'include/vcl/glyphitem.hxx')
-rw-r--r-- | include/vcl/glyphitem.hxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/include/vcl/glyphitem.hxx b/include/vcl/glyphitem.hxx index 02d783a3e166..d928bb954ee7 100644 --- a/include/vcl/glyphitem.hxx +++ b/include/vcl/glyphitem.hxx @@ -31,7 +31,11 @@ class SalLayoutGlyphsImpl; class VCL_DLLPUBLIC SalLayoutGlyphs final { - std::vector<SalLayoutGlyphsImpl*> m_pImpls; + SalLayoutGlyphsImpl* m_pImpl = nullptr; + // Extra items are in a dynamically allocated vector in order to save memory. + // The usual case should be that this stays unused (it should be only used + // when font fallback takes place). + std::vector<SalLayoutGlyphsImpl*>* m_pExtraImpls = nullptr; public: SalLayoutGlyphs() = default; @@ -42,11 +46,8 @@ public: SalLayoutGlyphs& operator=(const SalLayoutGlyphs&) = delete; SalLayoutGlyphs& operator=(SalLayoutGlyphs&&); - SalLayoutGlyphsImpl* Impl(unsigned int nLevel) const - { - return nLevel < m_pImpls.size() ? m_pImpls[nLevel] : nullptr; - } - void AppendImpl(SalLayoutGlyphsImpl* pImpl) { m_pImpls.push_back(pImpl); } + SalLayoutGlyphsImpl* Impl(unsigned int nLevel) const; + void AppendImpl(SalLayoutGlyphsImpl* pImpl); bool IsValid() const; void Invalidate(); |