Mercurial > dillo_port1.3
changeset 1298:9e939c62b7fe
don't calculate textWidth unnecessarily
author | corvid <corvid@lavabit.com> |
---|---|
date | Wed, 02 Sep 2009 04:52:37 +0000 |
parents | 1b4980dcee36 |
children | ad0d453e4f60 |
files | dw/textblock.cc |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/dw/textblock.cc Wed Sep 02 00:47:10 2009 +0000 +++ b/dw/textblock.cc Wed Sep 02 04:52:37 2009 +0000 @@ -1342,13 +1342,17 @@ if (wordIndex == hlEnd[layer].index) lastCharIdx = misc::min (hlEnd[layer].nChar, wordLen); - xStart = xWorld + layout->textWidth (word->style->font, - word->content.text, - firstCharIdx); - width = layout->textWidth (word->style->font, - word->content.text + firstCharIdx, - lastCharIdx - firstCharIdx); - + xStart = xWorld; + if (firstCharIdx) + xStart += layout->textWidth (word->style->font, + word->content.text, + firstCharIdx); + if (firstCharIdx == 0 && lastCharIdx == wordLen) + width = word->size.width; + else + width = layout->textWidth (word->style->font, + word->content.text + firstCharIdx, + lastCharIdx - firstCharIdx); if (width > 0) { /* Highlight text */ core::style::Color *wordBgColor;