File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -242,6 +242,7 @@ function spaceName(w: World, a: Atom): string | undefined {
242242 return r . kind === "sym" ? r . name : undefined ;
243243}
244244function resolveStates ( w : World , a : Atom ) : Atom {
245+ if ( w . store . size === 0 ) return a ; // no state cells: identity, skip the tree clone (hot path)
245246 if ( a . kind === "expr" ) {
246247 if ( opOf ( a ) === "State" && a . items . length === 2 ) {
247248 const g = a . items [ 1 ] ! ;
@@ -252,11 +253,13 @@ function resolveStates(w: World, a: Atom): Atom {
252253 return a ;
253254}
254255function subTokens ( w : World , a : Atom ) : Atom {
256+ if ( w . tokens . size === 0 ) return a ; // no bind! tokens: identity, skip the tree clone (hot path)
255257 if ( a . kind === "sym" ) return w . tokens . get ( a . name ) ?? a ;
256258 if ( a . kind === "expr" ) return expr ( a . items . map ( ( x ) => subTokens ( w , x ) ) ) ;
257259 return a ;
258260}
259261function wrapStates ( w : World , a : Atom ) : Atom {
262+ if ( w . store . size === 0 ) return a ; // no state cells: identity, skip the tree clone (hot path)
260263 if ( a . kind === "expr" ) {
261264 if ( opOf ( a ) === "State" && a . items . length === 2 ) {
262265 const g = a . items [ 1 ] ! ;
You can’t perform that action at this time.
0 commit comments