[webkit-changes] [40976] trunk/WebCore
Adam Treat
treat at kde.org
Fri Feb 13 08:57:40 PST 2009
On Friday 13 February 2009 11:20:18 am darin at apple.com wrote:
> Revision
> 40976
> Author
> darin at apple.com
> Date
> 2009-02-13 08:20:16 -0800 (Fri, 13 Feb 2009)
> Log Message
> 2009-02-12 Darin Adler <darin at apple.com>
>
> Reviewed by Oliver Hunt.
>
> Speed up document.write a bit.
>
> * bindings/js/JSHTMLDocumentCustom.cpp:
> (WebCore::documentWrite): Added. Uses SegmentedString to avoid
> conversion from UString to String and to avoid appending strings. Also
> added code to handle newlines efficiently.
> (WebCore::JSHTMLDocument::write): Changed to use documentWrite.
> (WebCore::JSHTMLDocument::writeln): Ditto.
>
> * dom/Document.cpp:
> (WebCore::Document::prepareToWrite): Added. Refactored the
> initialization part of write into a separate function for use in the
> JavaScript binding. (WebCore::Document::write): Changed to call
> prepareToWrite.
Why does the binding need this separate function? See below...
> + Document* activeDocument =
> asJSDOMWindow(exec->lexicalGlobalObject())->impl()->document(); +
> document->prepareToWrite(activeDocument);
> + if (Tokenizer* tokenizer = document->tokenizer())
> + tokenizer->write(segmentedString, false);
> }
Why do you call write on the tokenizer explicitly here instead of just doing
this:
document->write(segmentedString,activeDocument);
...which looks equivalent to me and this way you centralize the function where
all document.writes access the actual tokenizer like before.
Cheers,
Adam
More information about the webkit-changes
mailing list