From a2af9029410b20748b053bf0ca6f78ee27efef9e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 24 Apr 2013 23:40:18 +0300 Subject: in sdlfont add map for fast search in list. --- src/gui/sdlfont.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/gui/sdlfont.h') 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 +#include #include #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 search; }; /** @@ -139,6 +159,7 @@ class SDLFont final : public gcn::Font // Word surfaces cache int mCleanTime; + mutable TextChunkList mCache[CACHES_NUMBER]; }; #ifdef UNITTESTS -- cgit v1.2.3-60-g2f50