mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 22:17:41 +00:00
replace the map based width cache with an array based one.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15585 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7f94f08bbe
commit
1372f311d3
@ -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
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user