DOM/textarea-edit.html spends 35% of time in numGraphemeClusters
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2012 22:19:16 +0000 (22:19 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2012 22:19:16 +0000 (22:19 +0000)
commitcc86358dd240b678f24bb126cccae25a6259227a
tree1bec3b8d1054af1df3196d5969d0414b94a78b74
parente9adbcc1e69e958dcd9fbd674402101eb710e8f4
DOM/textarea-edit.html spends 35% of time in numGraphemeClusters
https://bugs.webkit.org/show_bug.cgi?id=98711

Reviewed by Kent Tamura.

Since the number of characters is always greater than the number of grapheme clusters,
we can avoid calling computeLengthForSubmission when the number of characters is less
than maxlength. We still have to count the number of LFs since they all need to be
converted into CRLFs. This improves WebKit's score on DOM/textarea-edit.html by 45%.

* html/HTMLTextAreaElement.cpp:
(WebCore::computeLengthForSubmission):
(WebCore::numberOfLineBreaks):
(WebCore::upperBoundForLengthForSubmission): Added.
(WebCore::HTMLTextAreaElement::handleBeforeTextInsertedEvent):
(WebCore::HTMLTextAreaElement::tooLong):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLTextAreaElement.cpp