MCPcopy
hub / github.com/BlueWallet/BlueWallet / getCachedMatrix

Function getCachedMatrix

components/QRCode.tsx:64–79  ·  view source on GitHub ↗
(value: string, ecl: ErrorCorrectionLevel)

Source from the content-addressed store, hash-verified

62const matrixCache = new Map<string, boolean[][]>();
63
64const getCachedMatrix = (value: string, ecl: ErrorCorrectionLevel): boolean[][] => {
65 const key = `${ecl}|${value}`;
66 const hit = matrixCache.get(key);
67 if (hit) {
68 matrixCache.delete(key);
69 matrixCache.set(key, hit);
70 return hit;
71 }
72 const m = encodeQR(value, 'raw', { ecc: eclMap[ecl], border: 0 });
73 matrixCache.set(key, m);
74 if (matrixCache.size > MATRIX_CACHE_MAX) {
75 const first = matrixCache.keys().next().value;
76 if (first !== undefined) matrixCache.delete(first);
77 }
78 return m;
79};
80
81type RenderPlan = {
82 N: number;

Callers 1

getCachedPlanFunction · 0.85

Calls 4

deleteMethod · 0.80
setMethod · 0.80
keysMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected