[Webkit-unassigned] [Bug 108881] Canvas fillText and measureText handle ideographic spaces differently

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Aug 16 06:31:40 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=108881





--- Comment #40 from Christophe Dumez <dchris at gmail.com>  2013-08-16 06:31:12 PST ---
(In reply to comment #39)
> Please comment on below piece of code :-
> 
> static void normalizeSpaces(String& text)
> {
>     unsigned textLength = text.length();
> 
>     unsigned i = 0;
>     for (; i != textLength; ++i) {
>         if (spaceNeedsReplacing(text[i]))
>             break;
>     }
> 
>     if (i == textLength)
>         return;
> 
>     WTF::Vector<UChar> charVector(textLength);
>     memcpy(&charVector, &text, i * sizeof(UChar));
>     charVector[i] = ' ';
>     ++i;
> 
>     for (; i != textLength; ++i) {
>         if (spaceNeedsReplacing(text[i]))
>             charVector[i] = ' ';
>         else
>             charVector[i] = text[i];
>     }
> 
>     text.adopt(charVector);
> }

Looks like you could use find in the beginning:
size_t find(CharacterMatchFunctionPtr matchFunction, unsigned start = 0) const;

> charVector[i] = ' ';
> ++i;

could be charVector[i++] = ' ';

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list