mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
Make it possible to clear the cache, used by the getB
function in src/core/pattern.js
While this cache will not contain a huge amount of data in practice, it's nonetheless a *global* cache that currently will never be cleared. This patch also removes the existing closure, since it shouldn't really be necessary nowadays given that the code is a JavaScript module which means that only explicitly listed properties will be exported.
This commit is contained in:
parent
93ce7c5a89
commit
628ca737dd
2 changed files with 22 additions and 18 deletions
|
@ -13,10 +13,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { clearPatternCaches } from "./pattern.js";
|
||||||
import { clearPrimitiveCaches } from "./primitives.js";
|
import { clearPrimitiveCaches } from "./primitives.js";
|
||||||
import { clearUnicodeCaches } from "./unicode.js";
|
import { clearUnicodeCaches } from "./unicode.js";
|
||||||
|
|
||||||
function clearGlobalCaches() {
|
function clearGlobalCaches() {
|
||||||
|
clearPatternCaches();
|
||||||
clearPrimitiveCaches();
|
clearPrimitiveCaches();
|
||||||
clearUnicodeCaches();
|
clearUnicodeCaches();
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,8 +411,9 @@ class MeshStreamReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getB = (function getBClosure() {
|
let bCache = Object.create(null);
|
||||||
function buildB(count) {
|
|
||||||
|
function buildB(count) {
|
||||||
const lut = [];
|
const lut = [];
|
||||||
for (let i = 0; i <= count; i++) {
|
for (let i = 0; i <= count; i++) {
|
||||||
const t = i / count,
|
const t = i / count,
|
||||||
|
@ -422,13 +423,14 @@ const getB = (function getBClosure() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return lut;
|
return lut;
|
||||||
}
|
}
|
||||||
const cache = Object.create(null);
|
function getB(count) {
|
||||||
|
return (bCache[count] ||= buildB(count));
|
||||||
|
}
|
||||||
|
|
||||||
return function (count) {
|
function clearPatternCaches() {
|
||||||
return (cache[count] ||= buildB(count));
|
bCache = Object.create(null);
|
||||||
};
|
}
|
||||||
})();
|
|
||||||
|
|
||||||
class MeshShading extends BaseShading {
|
class MeshShading extends BaseShading {
|
||||||
static MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
|
static MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
|
||||||
|
@ -1000,4 +1002,4 @@ function getTilingPatternIR(operatorList, dict, color) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export { getTilingPatternIR, Pattern };
|
export { clearPatternCaches, getTilingPatternIR, Pattern };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue