Skip to content
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

Projected arrays do not preserve sparse arrays #29

Open
ThomasMichon opened this issue Apr 2, 2015 · 0 comments
Open

Projected arrays do not preserve sparse arrays #29

ThomasMichon opened this issue Apr 2, 2015 · 0 comments

Comments

@ThomasMichon
Copy link
Collaborator

Observable arrays assume that their wrapped arrays can be sparse, and array change tracking appears to work on sparse arrays (even if it iterates numerically instead of by key). However, invoking map() on a sparse array produces an array which is no longer sparse, which significantly drops performance.

var source = ko.observableArray(new Array(100000));
// Object.keys(source()).length is 0
var projection = source.map(function (x) { return x * 2; });
// Object.keys(projection()).length is 100000

I get the impression that if the initial mapping process and the index update process iterated over the keys of the underlying arrays, then the projected array could remain sparse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant