-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the Glyph.matchesForCache
method (PR 13494 follow-up)
#15586
Remove the Glyph.matchesForCache
method (PR 13494 follow-up)
#15586
Conversation
Glyph.matchesForCache
method (PR 13494 follow-up)Glyph.matchesForCache
method (PR 13494 follow-up)
f08442b
to
3748c6e
Compare
This method, and its class, was originally added in PR 4453 to reduce memory usage when parsing text. Then PR 13494 extended the `Glyph`-representation slightly to also include the `charCode`, which made the `matchesForCache` method *effectively* redundant since most properties on a `Glyph`-instance indirectly depends on that one. The only exception is potentially `isSpace` in multi-byte strings. Also, something that I noticed when testing this code: The `matchesForCache` method never worked correctly for `Glyph`s containing `accent`-data, since Objects are passed by reference in JavaScript. For affected fonts, of which there's only a handful of examples in our test-suite, we'd fail to find an already existing `Glyph` because of this.
With the changes in the previous patch we can move the glyph-cache lookup to the top of the method and thus avoid a bunch of, in *almost* every case, completely unnecessary re-parsing for every `charCode`.
8b68f2c
to
fd35cda
Compare
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 1 Live output at: http://54.193.163.58:8877/d26682143e29a14/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/61d17a8ff4c9c07/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/61d17a8ff4c9c07/output.txt Total script time: 24.83 mins
Image differences available at: http://54.241.84.105:8877/61d17a8ff4c9c07/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/d26682143e29a14/output.txt Total script time: 28.58 mins
Image differences available at: http://54.193.163.58:8877/d26682143e29a14/reftest-analyzer.html#web=eq.log |
Note that being able to skip re-parsing this data over and over for every single rendered glyph is a small performance improvement. Some very quick |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can observe the small perf improvement in the profiler too.
LGTM, thank you.
This method, and its class, was originally added in PR #4453 to reduce memory usage when parsing text. Then PR #13494 extended the
Glyph
-representation slightly to also include thecharCode
, which made thematchesForCache
method effectively redundant since most properties on aGlyph
-instance indirectly depends on that one. The only exception is potentiallyisSpace
in multi-byte strings.Also, something that I noticed when testing this code: The
matchesForCache
method never worked correctly forGlyph
s containingaccent
-data, since Objects are passed by reference in JavaScript. For affected fonts, of which there's only a handful of examples in our test-suite, we'd fail to find an already existingGlyph
because of this.