Skip to content

Commit 717b14d

Browse files
author
Vlad Balin
committed
Detailed design of object creation optimization
1 parent eb959ec commit 717b14d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/record/transaction.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,23 @@ export class Record extends Transactional implements Owner {
352352
// TODO: Here we have the loop for all attributes.
353353
// There's the safe way to make it way faster by moving this transformation to the unrolled loop we have in 'defaults'.
354354
// It should substantially improve loading time for collections.
355+
// Or
356+
// Think of creating the multimode constructor packing all the stuff inside. Measure the gain.
357+
/*
358+
function Attributes( values, _attributes, record, options ){
359+
const { clone } = options;
360+
let _a, v;
361+
362+
_a = _attributes.${ key };
363+
v = values.${ key };
364+
if( clone ) v = _a.clone( v ) else if( v === void 0 ) v = ${ expr };
365+
v = this.${ key } = _a.transform( v, options, void 0, record );
366+
_a.handleChange( v, void 0, record );
367+
...
368+
}
369+
*/
370+
// f( v.${ attr } === void 0 ? ${ create } : v.${ attr } )
371+
// f( a.${ attr }.clone( v.${ attr } ) )
355372
this.forEachAttr( attributes, ( value : any, key : string, attr : AttributeUpdatePipeline ) => {
356373
const next = attributes[ key ] = attr.transform( value, options, void 0, this );
357374
attr.handleChange( next, void 0, this );

0 commit comments

Comments
 (0)