12014-01-12 Darin Adler <darin@apple.com>
2
3 Reduce use of String::characters
4 https://bugs.webkit.org/show_bug.cgi?id=126854
5
6 Reviewed by NOBODY (OOPS!).
7
8 * bindings/objc/WebScriptObject.mm:
9 (+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
10 Get rid of unneeded code to turn a WTF::String into an NSString, since that's
11 built into the WTF::String class.
12
13 * editing/CompositeEditCommand.cpp:
14 (WebCore::containsOnlyWhitespace): Use WTF::String's [] operator instead of
15 an explicit call to the characters function. Small performance cost.
16 * editing/TypingCommand.cpp:
17 (WebCore::TypingCommand::insertText): Ditto.
18
19 * editing/VisibleUnits.cpp:
20 (WebCore::startOfParagraph): Use reverseFind instead of writing our own loop.
21 (WebCore::endOfParagraph): Use find instead of writing our own loop.
22
23 * html/parser/HTMLParserIdioms.cpp:
24 (WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 instead of
25 characters since we have already checked is8Bit.
26 (WebCore::parseHTMLNonNegativeInteger): Ditto. Replace the length check with
27 a check of isNull since a zero length string could be 8 bit, but it's not
28 safe to call is8Bit on a null WTF::String. (That should probably be fixed.)
29
30 * inspector/ContentSearchUtils.cpp:
31 (WebCore::ContentSearchUtils::createSearchRegexSource): Use StringBuilder
32 instead of String in code that builds up a string one character at a time.
33 The old way was ridiculously slow because it allocated a new string for every
34 character; the new way still isn't all that efficient, but it's better. Also
35 changed to use strchr instead of WTF::String::find for special characters.
36
37 * inspector/InspectorStyleSheet.cpp:
38 (WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Use WTF::String's
39 [] operator instead of an explicit call to the characters function.
40 * inspector/InspectorStyleTextEditor.cpp:
41 (WebCore::InspectorStyleTextEditor::insertProperty): Ditto.
42 (WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
43 * platform/Length.cpp:
44 (WebCore::newCoordsArray): Ditto.
45
46 * platform/LinkHash.cpp:
47 (WebCore::visitedLinkHash): Use characters16 instead of characters since
48 we have already checked is8Bit. Replace the length check with a check of
49 isNull (as above in parseHTMLNonNegativeInteger).
50
51 * platform/graphics/Color.cpp:
52 (WebCore::Color::parseHexColor): Use characters16 since we already checked is8Bit.
53 (WebCore::Color::Color): Ditto.
54
55 * platform/graphics/TextRun.h:
56 (WebCore::TextRun::TextRun): Use characters16 instead of characters since
57 we have already checked is8Bit. Replace the length check with a check of
58 isNull (as above in parseHTMLNonNegativeInteger).
59
60 * platform/text/TextEncodingRegistry.cpp:
61 (WebCore::atomicCanonicalTextEncodingName): Use characters16 instead of
62 characters since we already checked is8Bit. Also use isEmpty instead of !length.
63
64 * rendering/RenderBlock.cpp:
65 (WebCore::RenderBlock::constructTextRun): Use characters16 instead of characters
66 since we have already checked is8Bit. Replace the length check with a check of
67 isNull (as above in parseHTMLNonNegativeInteger).
68
69 * rendering/RenderCombineText.cpp:
70 (WebCore::RenderCombineText::width): Check for zero length instead of checking
71 for null characters.
72
73 * svg/SVGFontElement.cpp:
74 (WebCore::SVGFontElement::registerLigaturesInGlyphCache): Rewrite ligatures
75 for loop and give local variables a better name. Construct the substring with
76 the substring function. Still a really inefficient approach -- allocating a new
77 string for every character is absurdly expensive.
78
79 * xml/XPathFunctions.cpp:
80 (WebCore::XPath::FunId::evaluate): Use String instead of StringBuilder. Still
81 not all that efficient, but better than before. Use substring to construct the
82 substring.
83
84 * xml/XPathNodeSet.h: Added begin and end functions so we can use a C++11 for
85 loop with this class.
86