Skip to content

Handle streamtube coordinates in string format and handle different data orders in isosurface and volume #4431

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 11 commits into from
Dec 30, 2019
3 changes: 3 additions & 0 deletions src/traces/streamtube/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ function distinctVals(col) {
function filter(arr, len) {
if(len === undefined) len = arr.length;

// no need for casting typed arrays to numbers
if(Lib.isTypedArray(arr)) return arr.slice(0, len);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use arr.subarray() for typed arrays, as .slice isn't supported in older browsers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.
Wondering if we need to slice the array at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slice (or subarry) is needed for distictVals to work correctly.
But it may be better not to slice if the length is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it may be better not to slice if the length is correct.

that could be a nice optimisation for typed arrays, but for regular arrays we'll need to slice in general to cast numerical-strings items w/o mutating.


var values = [];
for(var i = 0; i < len; i++) {
values[i] = +arr[i];
Expand Down