From 31f4803c0a3240dcbad24472693fe68a1deceeba Mon Sep 17 00:00:00 2001 From: JonStargaryen <sebastian.bittrich@rcsb.org> Date: Wed, 26 May 2021 09:21:42 -0700 Subject: [PATCH] no array copies --- src/extensions/anvil/algorithm.ts | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/extensions/anvil/algorithm.ts b/src/extensions/anvil/algorithm.ts index 27e5d7052..453c6cd71 100644 --- a/src/extensions/anvil/algorithm.ts +++ b/src/extensions/anvil/algorithm.ts @@ -79,17 +79,14 @@ const centroidHelper = new CentroidHelper(); async function initialize(structure: Structure, props: ANVILProps, accessibleSurfaceArea: AccessibleSurfaceArea): Promise<ANVILContext> { const l = StructureElement.Location.create(structure); const { label_atom_id, label_comp_id, x, y, z } = StructureProperties.atom; - const elementCount = structure.polymerResidueCount; const asaCutoff = props.asaCutoff / 100; centroidHelper.reset(); - let offsets = new Array<number>(elementCount); - let exposed = new Array<number>(elementCount); - let hydrophobic = new Array<boolean>(elementCount); + let offsets = new Array<number>(); + let exposed = new Array<number>(); + let hydrophobic = new Array<boolean>(); const vec = v3zero(); - let m = 0; - let n = 0; for (let i = 0, il = structure.units.length; i < il; ++i) { const unit = structure.units[i]; const { elements } = unit; @@ -119,20 +116,14 @@ async function initialize(structure: Structure, props: ANVILProps, accessibleSur centroidHelper.includeStep(vec); // keep track of offsets and exposed state to reuse - offsets[m++] = structure.serialMapping.getSerialIndex(l.unit, l.element); + offsets.push(structure.serialMapping.getSerialIndex(l.unit, l.element)); if (AccessibleSurfaceArea.getValue(l, accessibleSurfaceArea) / MaxAsa[label_comp_id(l)] > asaCutoff) { - exposed[n] = structure.serialMapping.getSerialIndex(l.unit, l.element); - hydrophobic[n] = isHydrophobic(label_comp_id(l)); - n++; + exposed.push(structure.serialMapping.getSerialIndex(l.unit, l.element)); + hydrophobic.push(isHydrophobic(label_comp_id(l))); } } } - // omit potentially empty tail - offsets = offsets.slice(0, m); - exposed = exposed.slice(0, n); - hydrophobic = hydrophobic.splice(0, n); - // calculate centroid and extent centroidHelper.finishedIncludeStep(); const centroid = v3clone(centroidHelper.center); -- GitLab