Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1600x 1600x 1600x 565x 725x 725x 565x 1600x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1160x 399x 514x 514x 399x 1160x 1160x 1160x 1160x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 692x 8448x 8448x 8448x 692x 692x | import Pool from './pool'; import { NodeCache, VTree } from './types'; const { protect, unprotect, memory } = Pool; /** * Ensures that vTree is not recycled during a render cycle. * * @param {VTree} vTree * @return {void} */ export function protectVTree(vTree) { protect(vTree); if (vTree.childNodes.length) { for (let i = 0; i < vTree.childNodes.length; i++) { protectVTree(vTree.childNodes[i]); } } } /** * Recycles a VTree by unprotecting itself, removing its DOM Node reference, and * recursively unprotecting all nested children. Resets the VTree's attributes * and childNode properties afterwards, as these can contribute to unwanted * increases in the heap. * * @param {VTree} vTree * @return {void} */ export function unprotectVTree(vTree) { if (vTree.childNodes.length) { for (let i = 0; i < vTree.childNodes.length; i++) { unprotectVTree(vTree.childNodes[i]); } } NodeCache.delete(vTree); unprotect(vTree); } /** * Collects any unused VTree's and puts them back into the free Set. This is * primarily used by tests, but could also be useful for specific niche cases * as a way to ease memory/CPU pressure when lots of temporary trees are * created but never used. * * @return {void} */ export function gc() { memory.allocated.forEach(vTree => { memory.free.add(vTree); memory.allocated.delete(vTree); NodeCache.delete(vTree); }); } |