Bug 154772 - Optimize parseHTMLInteger()
Summary: Optimize parseHTMLInteger()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-26 21:43 PST by Chris Dumez
Modified: 2016-02-27 10:30 PST (History)
6 users (show)

See Also:


Attachments
Patch (3.80 KB, patch)
2016-02-26 21:53 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (4.12 KB, patch)
2016-02-26 22:34 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (4.12 KB, patch)
2016-02-27 09:43 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-02-26 21:43:16 PST
Optimize parseHTMLInteger() now that it is used a lot more and that it has decent API test coverage.
Comment 1 Chris Dumez 2016-02-26 21:53:55 PST
Created attachment 272400 [details]
Patch
Comment 2 Ryosuke Niwa 2016-02-26 22:04:10 PST
Comment on attachment 272400 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272400&action=review

> Source/WebCore/html/parser/HTMLParserIdioms.cpp:176
> +    value = charactersToIntStrict(numberStart, position - numberStart, &ok);

Can we just compute the result in the above loop instead of calling this function?
We're just parsing decimal number here and we've already traversed the entire string.
Comment 3 Chris Dumez 2016-02-26 22:34:16 PST
Created attachment 272409 [details]
Patch
Comment 4 Ryosuke Niwa 2016-02-26 22:49:58 PST
Comment on attachment 272409 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272409&action=review

> Source/WebCore/html/parser/HTMLParserIdioms.cpp:178
> +    int result = 0;

Why don't we use unsigned here

> Source/WebCore/html/parser/HTMLParserIdioms.cpp:182
> +        if (result > maxMultiplier || (result == maxMultiplier && digitValue > (intMax % base) + isNegative))

So that we can simplify the second condition here?

Now that I'm seeing this code for overflow check, perhaps calling charactersToIntStrict wasn't that bad...
Comment 5 Chris Dumez 2016-02-27 09:43:13 PST
Created attachment 272418 [details]
Patch
Comment 6 WebKit Commit Bot 2016-02-27 10:30:52 PST
Comment on attachment 272418 [details]
Patch

Clearing flags on attachment: 272418

Committed r197255: <http://trac.webkit.org/changeset/197255>
Comment 7 WebKit Commit Bot 2016-02-27 10:30:56 PST
All reviewed patches have been landed.  Closing bug.