Skip to content
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

Convert {BaseViewer, PDFThumbnailViewer}._pagesRequests from an Array to a WeakMap #11350

Merged
merged 1 commit into from
Nov 21, 2019

Commits on Nov 21, 2019

  1. Convert {BaseViewer, PDFThumbnailViewer}._pagesRequests from an Arr…

    …ay to a WeakMap
    
    Obviously the `_pagesRequests` functionality is *mainly* used when `disableAutoFetch` is set, but it will also be used during ranged/streamed loading of documents.
    However, the `_pagesRequests` property is currently an Array which seems a bit strange:
    
     - Arrays are zero-indexed, but the first element will never actually be set in the code.
     - The `_pagesRequests` Array is never cleared, unless a new document is loaded, and once the `PDFDocumentProxy.getPage` call has resolved/rejected the element is just replaced by `null`.
     - Unless the document is browsed *in order* the resulting `_pagesRequests` Array can also be arbitrarily sparse.
    
    All in all, I don't believe that an Array is an appropriate data structure to use for this purpose.
    Snuffleupagus committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    0f73758 View commit details
    Browse the repository at this point in the history