Jochen Hoenicke wrote:
[...]
> It is probably slower if
> many different methods are called on the same character (since I don't
> have a cached CharAttr), but faster if they are called on similar
> characters (characters in the same block).
Unfortunately cachedBlock in your Character is possibly dangerous - if
thread will switch after compares and before return you can get a wrong
result. You would have to synchronize access to cachedBlock, which would
be probably slow enough to loss any performance benefits from it. I
suppose that just sticking to binary search is ok.
Maybe later we can do something faster, looking at space/speed benefits
- like creating constant size blocks, which would be accesible by just
shifting char. Something like
charData = data[block[ch>>11]+(ch&0x1f)];
All 32 bytes blocks which are the same would be shared.
Artur