Skip to content

Sort transform #1609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 10, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
do not slice array just to read its values in sort loop
  • Loading branch information
etpinard committed May 9, 2017
commit 9c70ee963d5af87c81e84af01cda3da81d45dbab
5 changes: 2 additions & 3 deletions src/transforms/sort.js
Original file line number Diff line number Diff line change
@@ -78,18 +78,17 @@ exports.calcTransform = function(gd, trace, opts) {

var target = opts.target;
var len = targetArray.length;

var arrayAttrs = PlotSchema.findArrayAttributes(trace);
var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray);
var indices = getIndices(opts, targetArray, d2c);

for(var i = 0; i < arrayAttrs.length; i++) {
var np = Lib.nestedProperty(trace, arrayAttrs[i]);
var arrayCopy = np.get().slice();
var arrayOld = np.get();
var arrayNew = new Array(len);

for(var j = 0; j < len; j++) {
arrayNew[j] = arrayCopy[indices[j]];
arrayNew[j] = arrayOld[indices[j]];
}

np.set(arrayNew);