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

Reduce object creation during parsing #6758

Merged
merged 4 commits into from
Nov 17, 2019

Conversation

benmccann
Copy link
Contributor

This is an alternative to #6750, which does not move _parsed out of metaData

Removed addElementAndReset because of a bug. insertElements was calling updateElement via addElementAndReset and then calling _parse. However, updateElement assumes that the parsing has already happened, so these were happening in the wrong order. Also, _parse assumes the metaData is already created and stored, so there was no possible way to call addElementAndReset without causing issues. The code now calls these methods in the correct order

It also renames _val to _parsed in doughnut.

src/core/core.datasetController.js Outdated Show resolved Hide resolved
for (i = start; i < start + count; ++i) {
const element = me.createMeta(me.dataElementType);
me._cachedMeta.data.splice(i, 0, element);
me._parse(i, 1);
Copy link
Member

Choose a reason for hiding this comment

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

Sould be more efficient to first create all, splice once, parse once, update each

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had been debating that and wasn't sure which would be more efficient. The splice is clearly more efficient the way you suggested, but we're now looping over the elements multiple times, so it wasn't clear to me which would be faster. I've updated it the way you suggested though

@etimberg etimberg merged commit f5b2b8d into chartjs:master Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants