-
Notifications
You must be signed in to change notification settings - Fork 224
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
fix the entrySelector calculation #178
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.
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; |
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.
L47 guarantees that L49 is always* integer
*) up to the font-impossible value of Math.log(2**750), at least.
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 think you may need to add a Babel plugin for the exponentiation operator
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'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.
Bump, again, because it's getting new issues filed over it. Can this be landed @devongovett? |
@devongovett switched |
Thanks @Pomax! |
The spec for the searchRange and entrySelector specifies the following constraints:
But the code was computing
searchRange
as just the power index, not the actual power of two that it should be.Fixes #149
Fixes #179