Skip to content

Commit

Permalink
perf(PiecewiseGaussianWidget): Replace forEach with for loop in setDa…
Browse files Browse the repository at this point in the history
…taArray

Results in ~5% speedup in volume rendering.
  • Loading branch information
thewtex committed Feb 12, 2018
1 parent 47d4061 commit 5e6a553
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/Interaction/Widgets/PiecewiseGaussianWidget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,12 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
while (model.histogram.length < model.numberOfBins) {
model.histogram.push(0);
}
array.forEach((value) => {
for(let i = 0, len = array.length; i < len; i++) {
const idx = Math.floor(
(model.numberOfBins - 1) * (Number(value) - min) / delta
(model.numberOfBins - 1) * (Number(array[i]) - min) / delta
);
model.histogram[idx] += 1;
});
}

// Smart Rescale Histogram
const sampleSize = Math.min(
Expand Down

0 comments on commit 5e6a553

Please sign in to comment.