Open WongYC-66 opened 1 day ago
Current modelInstance_meta_dirty use Object.
For performance point, says a model has 100 property. Is Set( ) going to be faster?
Array.some() would take O(N) or worse case 100 iterations to return .
// Current: isDirty(attribute?: ModelKey<this>): boolean { if (attribute) return !!this._meta._dirty[attribute as string]; // return this._meta._dirty whereas the boolean value is true return Object.keys(this._meta._dirty).some(key => this._meta._dirty[key]); // O(N) }
Consider this.
model_meta_dirty = new Set() // add "dirty" attribute isDirty(attribute?: ModelKey<this>): boolean { return this.meta_dirty.size !== 0 || this.meta_dirty.has(attribute) // O(1) }
Can, this improvement should be quite good, you may improve it
I think this one should be able to close it
im still working on this, having some syntax error, will update here again
Current modelInstance_meta_dirty use Object.
For performance point, says a model has 100 property. Is Set( ) going to be faster?
Array.some() would take O(N) or worse case 100 iterations to return .
Consider this.