1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #10275 from Snuffleupagus/trees-get-binary-search

Fix `NameOrNumberTree.get` to actually perform a binary search to find the requested key
This commit is contained in:
Tim van der Meij 2018-11-24 20:51:12 +01:00 committed by GitHub
commit 87e3fb8413
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1686,7 +1686,7 @@ class NameOrNumberTree {
while (l <= r) {
// Check only even indices (0, 2, 4, ...) because the
// odd indices contain the actual data.
const m = (l + r) & ~1;
const tmp = (l + r) >> 1, m = tmp + (tmp & 1);
const currentKey = xref.fetchIfRef(entries[m]);
if (key < currentKey) {
r = m - 2;