]> git.lyx.org Git - features.git/commitdiff
speed up symbol panel population
authorAndré Pönitz <poenitz@gmx.net>
Fri, 21 Mar 2008 18:55:26 +0000 (18:55 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 21 Mar 2008 18:55:26 +0000 (18:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23887 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiSymbols.cpp

index f2576a669d43b8ff93f169be3e2a58d4afec83c7..43c462d589d30b1e8c7a517f5f6fb09c4968ef86 100644 (file)
@@ -148,12 +148,21 @@ const int no_blocks = sizeof(unicode_blocks) / sizeof(UnicodeBlocks);
 
 QString getBlock(char_type c)
 {
-       int i = 0;
-       while (c > unicode_blocks[i].end && i < no_blocks)
-               ++i;
-       if (!unicode_blocks[i].name.isEmpty())
-               return unicode_blocks[i].name;
-       return QString();
+       // store an educated guess for the next search
+       static int lastBlock = 0;
+
+       if (c < unicode_blocks[lastBlock].start
+        || c > unicode_blocks[lastBlock].end)
+       {
+               // guess was wrong. do a real search.
+               int i = 0;
+               while (c > unicode_blocks[i].end && i < no_blocks)
+                       ++i;
+               if (unicode_blocks[i].name.isEmpty())
+                       return QString();
+               lastBlock = i;
+       }
+       return unicode_blocks[lastBlock].name;
 }