Less GC, no re-declare array across iterations

This commit is contained in:
Pitchaya Boonsarngsuk
2018-02-02 13:26:03 +00:00
parent 474bd677ae
commit 636779322b

View File

@@ -19,13 +19,14 @@ import {placeNearToNearestNeighbour} from "./interpCommon";
* placement of each interpolated point
*/
export default function(sampleSet, remainderSet, distanceFn, endingIts) {
let sampleSubset = takeSampleFrom(sampleSet, Math.sqrt(sampleSet.length)).sample;
let
sampleSubset = takeSampleFrom(sampleSet, Math.sqrt(sampleSet.length)).sample,
sampleSubsetDistanceCache = [];
// For each datapoint "node" to be interpolated
for (let i = remainderSet.length-1; i>=0; i--) {
let
node = remainderSet[i],
sampleSubsetDistanceCache = [],
node = remainderSet[i],,
nearestSample, minDist, sample, dist, index;
// For each datapoint "sample" in the sample set