speed up symbol panel population

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23887 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-03-21 18:55:26 +00:00
parent 94e0c24753
commit 0011f47885

View 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;
}