diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-24 23:40:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-25 16:35:59 +0300 |
commit | a2af9029410b20748b053bf0ca6f78ee27efef9e (patch) | |
tree | 3754ad6f8ebd51bf54ccc041bb00e2e7f5eebbdc /src/gui/sdlfont.h | |
parent | 0d300e7aa5699154810af67282dacbcd65929768 (diff) | |
download | manaplus-a2af9029410b20748b053bf0ca6f78ee27efef9e.tar.gz manaplus-a2af9029410b20748b053bf0ca6f78ee27efef9e.tar.bz2 manaplus-a2af9029410b20748b053bf0ca6f78ee27efef9e.tar.xz manaplus-a2af9029410b20748b053bf0ca6f78ee27efef9e.zip |
in sdlfont add map for fast search in list.
Diffstat (limited to 'src/gui/sdlfont.h')
-rw-r--r-- | src/gui/sdlfont.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index 2e5376148..41edf4145 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -34,12 +34,31 @@ #endif #include <list> +#include <map> #include <string> #include "localconsts.h" class Image; +const unsigned int CACHES_NUMBER = 256; + +class SDLTextChunkSmall +{ + public: + SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, + const gcn::Color &color1); + + SDLTextChunkSmall(const SDLTextChunkSmall &old); + + bool operator==(const SDLTextChunkSmall &chunk) const; + bool operator<(const SDLTextChunkSmall &chunk) const; + + std::string text; + gcn::Color color; + gcn::Color color2; +}; + class SDLTextChunk final { public: @@ -79,6 +98,7 @@ class TextChunkList final SDLTextChunk *start; SDLTextChunk *end; uint32_t size; + std::map<SDLTextChunkSmall, SDLTextChunk*> search; }; /** @@ -139,6 +159,7 @@ class SDLFont final : public gcn::Font // Word surfaces cache int mCleanTime; + mutable TextChunkList mCache[CACHES_NUMBER]; }; #ifdef UNITTESTS |