-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Let getVisibleElements
return a Set containing the visible element id
s
#14219
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
Let getVisibleElements
return a Set containing the visible element id
s
#14219
Conversation
} | ||
|
||
/** | ||
* @param {number} pageNumber | ||
*/ | ||
isPageCached(pageNumber) { | ||
if (!this.pdfDocument || !this._buffer) { |
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.
Slightly unrelated to the rest of the patch, but: Note that this._buffer
will always be defined whenever this.pdfDocument
is set.
if (!pageView) { | ||
return false; | ||
} |
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.
Slightly unrelated to the rest of the patch, but: Given the existing validation just above it shouldn't be possible for pageView
to be undefined here, and in any case passing undefined
to the PDFPageViewBuffer.has
-method won't break anything.
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/76a28cbc05ce67c/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/76a28cbc05ce67c/output.txt Total script time: 4.23 mins Published |
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.
Looks like a good improvement. r=me once rebased; thanks!
…`id`s Note how in `PDFPageViewBuffer.resize` we're manually iterating through the visible pages in order to build a Set of the visible page `id`s. By instead moving the building of this Set into the `getVisibleElements` helper function, as part of the existing parsing, this code becomes *ever so slightly* more efficient. Furthermore, more direct access to the visible page `id`s also come in handy in other parts of the viewer as well. In the `BaseViewer.isPageVisible` method we no longer need to loop through the visible pages, but can instead directly check if the pageNumber is visible. In the `PDFRenderingQueue.getHighestPriority` method, when checking for "holes" in the page layout, we can also avoid some unnecessary look-ups this way.
The way that we're currently handling the last-`id` is very old, and there's no longer any good reason to special-case things when only one thumbnail is visible. Furthermore, we can also modernize the loop slightly by using `for...of` instead of `Array.prototype.some()` when checking for fully visible thumbnails.
ece6728
to
e78e4e7
Compare
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/97ad3126ba9d731/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 1 Live output at: http://54.193.163.58:8877/09eea1a0136b257/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/97ad3126ba9d731/output.txt Total script time: 3.92 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/09eea1a0136b257/output.txt Total script time: 6.35 mins
|
Note how in
PDFPageViewBuffer.resize
we're manually iterating through the visible pages in order to build a Set of the visible pageid
s. By instead moving the building of this Set into thegetVisibleElements
helper function, as part of the existing parsing, this code becomes ever so slightly more efficient.Furthermore, more direct access to the visible page
id
s also come in handy in other parts of the viewer as well.In the
BaseViewer.isPageVisible
method we no longer need to loop through the visible pages, but can instead directly check if the pageNumber is visible.In the
PDFRenderingQueue.getHighestPriority
method, when checking for "holes" in the page layout, we can also avoid some unnecessary look-ups this way.