fix the entrySelector calculation#178
Merged
devongovett merged 4 commits intofoliojs:masterfrom Nov 6, 2018
Pomax:patch-1
Merged
fix the entrySelector calculation#178devongovett merged 4 commits intofoliojs:masterfrom Pomax:patch-1
devongovett merged 4 commits intofoliojs:masterfrom
Pomax:patch-1
Conversation
The spec for the searchRange and entrySelector specified the following: >uint16 searchRange (Maximum power of 2 <= numTables) x 16. >uint16 entrySelector Log2(maximum power of 2 <= numTables). >uint16 rangeShift NumTables x 16-searchRange.
Pomax
commented
Oct 10, 2018
| this.entrySelector = Math.floor(this.searchRange / Math.LN2); | ||
| let maxPowerOf2 = 2 ** Math.floor((Math.log(this.numTables) / Math.LN2)); | ||
| this.searchRange = maxPowerOf2 * 16; | ||
| this.entrySelector = Math.log(maxPowerOf2) / Math.LN2; |
Contributor
Author
There was a problem hiding this comment.
L47 guarantees that L49 is always* integer
*) up to the font-impossible value of Math.log(2**750), at least.
Member
There was a problem hiding this comment.
I think you may need to add a Babel plugin for the exponentiation operator
Contributor
Author
There was a problem hiding this comment.
I'll rewrite it to Math.pow form - eventually IE will be dead and all those can be cleaned up, until then it's not really worth asking babel to do the conversion for.
Contributor
Author
Contributor
Author
|
Bump, again, because it's getting new issues filed over it. Can this be landed @devongovett? |
Contributor
Author
|
@devongovett switched |
devongovett
approved these changes
Nov 6, 2018
Member
|
Thanks @Pomax! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The spec for the searchRange and entrySelector specifies the following constraints:
But the code was computing
searchRangeas just the power index, not the actual power of two that it should be.Fixes #149
Fixes #179