Skip to content

Commit c58d480

Browse files
committed
Cache __value
1 parent 5e90d43 commit c58d480

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cdb/Module.hx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,14 @@ class Module {
632632
});
633633

634634
var exprs = [];
635+
exprs.push(macro var obj : Dynamic = cast obj);
636+
exprs.push(macro if( obj.__value != null ) return obj.__value);
637+
635638
for( col in s.columns ) {
636639
if( col.kind == Hidden ) continue;
637640
var colName = col.name;
638641
var caseName = makeTypeName(col.name);
639-
exprs.push(macro if( v.$colName != null ) return $i{caseName}(cast v.$colName));
642+
exprs.push(macro if( obj.$colName != null ) return obj.__value = $i{caseName}(cast obj.$colName));
640643
}
641644
exprs.push(macro throw "No polymorph value set");
642645
types.push({
@@ -652,7 +655,7 @@ class Module {
652655
kind : FFun( {
653656
ret : tname.toComplex(),
654657
expr : macro return $b{exprs},
655-
args : [{ name : "v", type: def.toComplex(), opt:false}],
658+
args : [{ name : "obj", type: def.toComplex(), opt:false}],
656659
}),
657660
}
658661
]

0 commit comments

Comments
 (0)