Convert the pagesRefCache
, on PDFLinkService
, from an Object to a Map
This seems like a more appropriate data structure, and as part of these changes the property was also converted to a *private* one.
This commit is contained in:
parent
fc31e1ba87
commit
00aa9811e6
@ -103,6 +103,8 @@ function addLinkAttributes(link, { url, target, rel, enabled = true } = {}) {
|
|||||||
* @implements {IPDFLinkService}
|
* @implements {IPDFLinkService}
|
||||||
*/
|
*/
|
||||||
class PDFLinkService {
|
class PDFLinkService {
|
||||||
|
#pagesRefCache = new Map();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {PDFLinkServiceOptions} options
|
* @param {PDFLinkServiceOptions} options
|
||||||
*/
|
*/
|
||||||
@ -122,14 +124,12 @@ class PDFLinkService {
|
|||||||
this.pdfDocument = null;
|
this.pdfDocument = null;
|
||||||
this.pdfViewer = null;
|
this.pdfViewer = null;
|
||||||
this.pdfHistory = null;
|
this.pdfHistory = null;
|
||||||
|
|
||||||
this._pagesRefCache = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setDocument(pdfDocument, baseUrl = null) {
|
setDocument(pdfDocument, baseUrl = null) {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
this.pdfDocument = pdfDocument;
|
this.pdfDocument = pdfDocument;
|
||||||
this._pagesRefCache = Object.create(null);
|
this.#pagesRefCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
setViewer(pdfViewer) {
|
setViewer(pdfViewer) {
|
||||||
@ -505,7 +505,7 @@ class PDFLinkService {
|
|||||||
}
|
}
|
||||||
const refStr =
|
const refStr =
|
||||||
pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
|
pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
|
||||||
this._pagesRefCache[refStr] = pageNum;
|
this.#pagesRefCache.set(refStr, pageNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -517,7 +517,7 @@ class PDFLinkService {
|
|||||||
}
|
}
|
||||||
const refStr =
|
const refStr =
|
||||||
pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
|
pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
|
||||||
return this._pagesRefCache?.[refStr] || null;
|
return this.#pagesRefCache.get(refStr) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user