]> git.lyx.org Git - features.git/commitdiff
CharMetrics: use short int instead of int. This halves the memory required for the...
authorAbdelrazak Younes <younes@lyx.org>
Fri, 1 Dec 2006 23:45:06 +0000 (23:45 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 1 Dec 2006 23:45:06 +0000 (23:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16129 a592a061-630c-0410-9148-cb99ea01b6c8

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

index d915a6f94ebd61027d1c0c64f3180377cc526ed8..165c6459f2cac6128f4bdc70d32a674e7585c4e2 100644 (file)
@@ -26,7 +26,7 @@ namespace frontend {
 
 namespace {
 // Used for checking initialisation state of the C-ish metrics table.
-const int BadMetrics = -1000;
+const short int BadMetrics = -1000;
 }
 
 
@@ -34,7 +34,7 @@ GuiFontMetrics::GuiFontMetrics(QFont const & font)
 : metrics_(font), smallcaps_metrics_(font), smallcaps_shape_(false)
 {
 #ifdef USE_LYX_FONTCACHE
- for (int i = 0; i != MaxCharType; ++i) {
+ for (size_t i = 0; i != MaxCharType; ++i) {
         metrics_cache_[i].width = BadMetrics;
         metrics_cache_[i].ascent = BadMetrics;
         metrics_cache_[i].descent = BadMetrics;
@@ -188,8 +188,8 @@ int GuiFontMetrics::descent(char_type c) const
 void GuiFontMetrics::fillCache(unsigned short val) const
 {
        QRect const & r = metrics_.boundingRect(QChar(val));
-       metrics_cache_[val].descent = r.bottom() + 1;
-       metrics_cache_[val].ascent = -r.top();
+       metrics_cache_[val].descent = static_cast<short>(r.bottom() + 1);
+       metrics_cache_[val].ascent = static_cast<short>(-r.top());
        // We could as well compute the width but this is not really
        // needed for now as it is done directly in width() below.
        //metrics_cache_[val].width = metrics_.width(QChar(val));
@@ -204,8 +204,10 @@ int GuiFontMetrics::width(char_type c) const
        // its display is not supported.
        BOOST_ASSERT(c < MaxCharType);
        unsigned short val = static_cast<unsigned short>(c);
-       if (metrics_cache_[val].width == BadMetrics)
-               metrics_cache_[val].width = metrics_.width(QChar(val));
+       if (metrics_cache_[val].width == BadMetrics) {
+               metrics_cache_[val].width 
+                       = static_cast<short>(metrics_.width(QChar(val)));
+       }
 
        return metrics_cache_[val].width;
 }
index f3c87adc289d5c4e1336c9bb082fd5196062840b..f7360506ec1aa4b2ab080b9a3271db11e7f75099 100644 (file)
@@ -31,9 +31,9 @@ size_t const MaxCharType = 65536;
 
 struct CharMetrics
 {
-       int width;
-       int ascent;
-       int descent;
+       short int width;
+       short int ascent;
+       short int descent;
 };