c35bbd11b0
It is quite confusing that the custom function is called `log2` while it actually returns the ceiling value and handles zero and negative values differently than the native function. To resolve this, we add a comment that explains these differences and make the function use the native `Math` functions internally instead of using our own custom logic. To verify that the function does what we expect, we add unit tests. All browsers except for IE support `Math.log2` for quite a long time already (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2). For IE, we use the core-js polyfill. According to the microbenchmark at https://jsperf.com/log2-pdfjs/1, using the native functions should also be faster, in my testing almost six times as fast. |
||
---|---|---|
.. | ||
chromium | ||
features | ||
font | ||
pdfs | ||
resources | ||
stats | ||
ttx | ||
unit | ||
.eslintrc | ||
.gitignore | ||
annotation_layer_builder_overrides.css | ||
downloadutils.js | ||
driver.js | ||
test_manifest.json | ||
test_slave.html | ||
test.js | ||
testutils.js | ||
text_layer_test.css | ||
webbrowser.js | ||
webserver.js |