- 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;
+ // "clever reset"
+ if (c < 0x7f)
+ lastBlock = 0;
+
+ // off the end already
+ if (lastBlock == no_blocks)
+ return QString();
+
+ // c falls into a covered area, and we can guess which
+ if (c >= unicode_blocks[lastBlock].start
+ && c <= unicode_blocks[lastBlock].end)
+ return qt_(unicode_blocks[lastBlock].name);
+
+ // c falls into an uncovered area, but we can guess which
+ if (c > unicode_blocks[lastBlock].end
+ && c < unicode_blocks[lastBlock + 1].start)
+ return QString();
+
+ // guessing was wrong so far. do a real search.
+ int i = 0;
+ while (c > unicode_blocks[i].end && i < no_blocks)
+ ++i;
+ if (i == no_blocks)
+ return QString();
+ lastBlock = i;
+ //LYXERR0("fail: " << int(c) << ' ' << lastBlock);
+ return qt_(unicode_blocks[lastBlock].name);