From ead25d6a9c946b6bdf1327881917c04869d2b896 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Sun, 8 Jan 2023 20:56:20 -0800 Subject: [PATCH] tweak BoundaryHelper performance --- src/mol-math/geometry/boundary-helper.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mol-math/geometry/boundary-helper.ts b/src/mol-math/geometry/boundary-helper.ts index c49ff1afd..6f91c16ea 100644 --- a/src/mol-math/geometry/boundary-helper.ts +++ b/src/mol-math/geometry/boundary-helper.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2020-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -13,6 +13,7 @@ import { Box3D } from './primitives/box3d'; export class BoundaryHelper { private dir: Vec3[]; + private dirLength: number; private minDist: number[] = []; private maxDist: number[] = []; @@ -56,13 +57,13 @@ export class BoundaryHelper { } includePosition(p: Vec3) { - for (let i = 0, il = this.dir.length; i < il; ++i) { + for (let i = 0; i < this.dirLength; ++i) { this.computeExtrema(i, p); } } includePositionRadius(center: Vec3, radius: number) { - for (let i = 0, il = this.dir.length; i < il; ++i) { + for (let i = 0; i < this.dirLength; ++i) { this.computeSphereExtrema(i, center, radius); } } @@ -101,7 +102,7 @@ export class BoundaryHelper { } reset() { - for (let i = 0, il = this.dir.length; i < il; ++i) { + for (let i = 0; i < this.dirLength; ++i) { this.minDist[i] = Infinity; this.maxDist[i] = -Infinity; this.extrema[i * 2] = Vec3(); @@ -112,6 +113,7 @@ export class BoundaryHelper { constructor(quality: EposQuality) { this.dir = getEposDir(quality); + this.dirLength = this.dir.length; this.reset(); } } -- GitLab