Reduce object creation during parsing#6758
Merged
etimberg merged 4 commits intochartjs:masterfrom Nov 17, 2019
Merged
Conversation
b50cad8 to
df372ae
Compare
kurkle
reviewed
Nov 17, 2019
src/core/core.datasetController.js
Outdated
| for (i = start; i < start + count; ++i) { | ||
| const element = me.createMeta(me.dataElementType); | ||
| me._cachedMeta.data.splice(i, 0, element); | ||
| me._parse(i, 1); |
Member
There was a problem hiding this comment.
Sould be more efficient to first create all, splice once, parse once, update each
Contributor
Author
There was a problem hiding this comment.
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
kurkle
approved these changes
Nov 17, 2019
Closed
etimberg
approved these changes
Nov 17, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an alternative to #6750, which does not move
_parsedout ofmetaDataRemoved
addElementAndResetbecause of a bug.insertElementswas callingupdateElementviaaddElementAndResetand then calling_parse. However,updateElementassumes that the parsing has already happened, so these were happening in the wrong order. Also,_parseassumes themetaDatais already created and stored, so there was no possible way to calladdElementAndResetwithout causing issues. The code now calls these methods in the correct orderIt also renames
_valto_parsedin doughnut.