Add caching of text labels at the UTF8 level
authorBen Avison <bavison@riscosopen.org>
Mon, 9 Dec 2013 15:28:15 +0000 (15:28 +0000)
committerBen Avison <bavison@riscosopen.org>
Mon, 9 Dec 2013 15:42:51 +0000 (15:42 +0000)
commit2d0af45eeaac45db043c1c5a0bd312257a64d480
tree77ce80404a2f287b475e9c29c5f404f4178fb563
parent3b282c90e8abff0f9ad8a1c3232848f343f5cbca
Add caching of text labels at the UTF8 level

Previously, CGUITextLayout::Update converted its string argument from UTF8 to
UTF16, then passed it to CGUITextLayout::UpdateW, where it was compared
against a cached copy of the string (in its UTF16 form). However, the
conversion itself was taking up a reasonable chunk of CPU time.

This patch adds a similar cache of the string in its UTF8 form to the Update
method, and splits the non-cache part of UpdateW into a separate function, so
we can bypass it the case where we've tested it against the UTF8 cache.

I have measured the effect while the Videos window of the default skin was
open (but idle) on a Raspberry Pi, and this reduced the CPU usage by 2.9%
from 39.1% to 36.2%:

          Before          After
          Mean   StdDev   Mean   StdDev  Confidence  Change
IdleCPU%  39.1   0.9      36.2   0.5     100.0%      +8.1%
xbmc/guilib/GUITextLayout.cpp
xbmc/guilib/GUITextLayout.h