sylvainpolletvillard / ObjectModel

Strong Dynamically Typed Object Modeling for JavaScript
http://objectmodel.js.org
MIT License
467 stars 30 forks source link

perf: Optimize mutator methods definition check #95

Closed sylvainpolletvillard closed 6 years ago

sylvainpolletvillard commented 6 years ago

The way ObjectModel currently validates mutative method calls on list models implies to validate the whole model for every mutation. This is suboptimal and a perf killer for some usecases (see https://github.com/sylvainpolletvillard/ObjectModel/issues/94)

Proposed solution:

I did not find a case where a list element had to be checked again, that was not part of the mutator method arguments.

Current list of arguments indexes to check def / autocast is:

Array

Map

Set

sylvainpolletvillard commented 6 years ago

Done and released as v3.7.1

cc @gotjoshua: you should no longer have a perf penalty by assigning the items one by one