DescriptionHTMLTokenizer: Fold isASCIIUpper() / isASCIILower() cases
I noticed that NextToken() had a bunch of code doing:
if (IsASCIIUpper(c)) {
doStuff(ToLowerCase(c));
} else if (IsASCIILower(c)) {
doStuff(c);
}
Since lowercasing is done by just setting the 0x20 bit, we can fold it into the
range check and always lowercase:
if (IsASCIIAlpha(c)) {
doStuff(ToLowerCase(c));
}
This actually brings the code closer to the tokenization spec which for these
states does not separate between upper- and lower-case inputs.
I tried to measure the performance of this by modifying
PerformanceTests/resources/runner.js to run 1000 iterations and running the
html-parser.html test:
$ tools/perf/run_benchmark run blink_perf.parser \
--story-filter=html-parser.html \
--browser-executable=/work/chromium/src/out/release/content_shell
However I could see no change in performance.
Without my change:
avg 379.1670899999993 ms
median 381.46249999999054 ms
stdev 45.56871307699382 ms
min 253.66499999997905 ms
max 1199.0950000000007 ms
With my change:
avg 376.9821549999998 ms
median 381.8125 ms
stdev 42.23547601324007 ms
min 254.27000000000407 ms
max 1127.37 ms
This does remove ~100 lines of code and shave ~1 KB off the object file size
which is always something. And it should be faster, really.
BUG=none
Review-Url: https://codereview.chromium.org/2827653003
Cr-Commit-Position: refs/heads/master@{#465690}
Committed: https://chromium.googlesource.com/chromium/src/+/d2e7b9cf0ef86f473dfce65d0317ead63e7984a8
Patch Set 1 #Patch Set 2 : Fix presubmit checks about braces #
Total comments: 1
Patch Set 3 : Rebase #Messages
Total messages: 18 (7 generated)
|