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
}
#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
/// 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
};