]> git.lyx.org Git - features.git/commitdiff
replace the map based width cache with an array based one.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 27 Oct 2006 22:46:36 +0000 (22:46 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 27 Oct 2006 22:46:36 +0000 (22:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15585 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiFontMetrics.C
src/frontends/qt4/GuiFontMetrics.h

index 080a3f45c09561025e61f2588d9eeb02f5da6c0b..57830f082ad03c63401700f97e397a1daaa04aeb 100644 (file)
@@ -31,6 +31,10 @@ namespace frontend {
 GuiFontMetrics::GuiFontMetrics(QFont const & font)
 : metrics_(font), smallcaps_metrics_(font), smallcaps_shape_(false)
 {
+#ifdef USE_LYX_FONTCACHE
+  for (int i = 0; i != 65536; ++i)
+    widthcache_[i] = -1;
+#endif
 }
 
 
@@ -184,13 +188,9 @@ void GuiFontMetrics::buttonText(docstring const & str,
 #ifdef USE_LYX_FONTCACHE
 int GuiFontMetrics::width(unsigned short val) const
 {
-       GuiFontMetrics::WidthCache::const_iterator cit = widthcache.find(val);
-       if (cit != widthcache.end())
-               return cit->second;
-
-       int const w = metrics_.width(QChar(val));
-       widthcache[val] = w;
-       return w;
+       if (widthcache_[val] == -1)
+               widthcache_[val] = metrics_.width(QChar(val));
+       return widthcache_[val];
 }
 #endif
 
index 08e6975c6cbb181509c106c90a63888060ec8a15..924c0e0cd61de3851a1fb5f4c0297a521de64581 100644 (file)
@@ -73,9 +73,8 @@ private:
        /// Return pixel width for the given unicode char
        int width(unsigned short val) const;
 
-       typedef std::map<unsigned short, int> WidthCache;
        /// Cache of char widths
-       mutable WidthCache widthcache;
+       mutable int widthcache_[65536];
 #endif // USE_LYX_FONTCACHE
 };