From 94e7820bafcc25bbab4db0b9c51346b3ab55238b Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Thu, 24 Oct 2019 07:40:35 +0200
Subject: [PATCH] mol-data: SortedArray fix
---
src/mol-data/int/impl/sorted-array.ts | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/mol-data/int/impl/sorted-array.ts b/src/mol-data/int/impl/sorted-array.ts
index 9aed13025..f0eecf725 100644
--- a/src/mol-data/int/impl/sorted-array.ts
+++ b/src/mol-data/int/impl/sorted-array.ts
@@ -188,17 +188,13 @@ export function union(a: Nums, b: Nums): Nums {
if (commonCount === lenA) return b;
const indices = new Int32Array(lenA + lenB - commonCount);
- let offset = 0;
+ let i = 0, j = 0, offset = 0;
// insert the "prefixes"
- let k = 0;
- for (k = 0; k < startI; k++) indices[offset++] = a[k];
- k = 0;
- while (k <= startJ && a[startI] > b[k]) indices[offset++] = b[k++];
+ for (i = 0; i < startI; i++) indices[offset++] = a[i];
+ while (j < endJ && a[startI] > b[j]) indices[offset++] = b[j++];
// insert the common part
- let i = startI;
- let j = startJ;
while (i < endI && j < endJ) {
const x = a[i], y = b[j];
if (x < y) { indices[offset++] = x; i++; }
--
GitLab