avoid using _.each on set method #30
Open
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.
Models with an attribute named 'length' will make this each work as an array.
From underscore docs
I do not check for
hasOwnPropertyin theforstatement in the new code because it's not done inBackboneeither so, just to keep things the same.Explanation:
We have been using
trackitfor a while with Directus. We used to have a weird bug that we weren't able to reproduce, after a long research and testing we find out the problem was_.each, we have models that represents columns, a column can have alengthbut when we use columns with small length number 10, 100, 255, this wasn't noticeable, then we started usingMEDIUMTEXTandLONGTEXTwhich translate to a16,777,215and4,294,967,295which takes time to process an array of that length, blocking the page from a couple of seconds to minutes.