JS: small speed improvement for typescript.js of ~1%
Taco de Wolff
1 year, 11 months ago
280 | 280 | for i, vorig := range s.Undeclared { |
281 | 281 | // no need to evaluate vorig.Link as vorig.Data stays the same |
282 | 282 | if 0 < vorig.Uses && vorig.Decl == NoDecl { |
283 | if v := s.Parent.findDeclared(vorig.Data, false); v != nil { | |
284 | // check if variable is declared in parent scope | |
283 | if v := s.Parent.findUndeclared(vorig.Data); v != nil { | |
284 | // check if variable is already used before in parent scope | |
285 | 285 | v.Uses += vorig.Uses |
286 | 286 | vorig.Link = v |
287 | 287 | s.Undeclared[i] = v // point reference to existing var (to avoid many Link chains) |
288 | } else if v := s.Parent.findUndeclared(vorig.Data); v != nil { | |
289 | // check if variable is already used before in parent scope | |
288 | } else if v := s.Parent.findDeclared(vorig.Data, false); v != nil { | |
289 | // check if variable is declared in parent scope | |
290 | 290 | v.Uses += vorig.Uses |
291 | 291 | vorig.Link = v |
292 | 292 | s.Undeclared[i] = v // point reference to existing var (to avoid many Link chains) |
305 | 305 | for _, vorig := range s.Declared { |
306 | 306 | // no need to evaluate vorig.Link as vorig.Data stays the same, and Link is always nil in Declared |
307 | 307 | // vorig.Uses will be atleast 1 |
308 | if v := s.Parent.findDeclared(vorig.Data, false); v != nil { | |
309 | // check if variable has been declared in this scope | |
308 | if v := s.Parent.findUndeclared(vorig.Data); v != nil { | |
309 | // check if variable is already used before in the current or lower scopes | |
310 | 310 | v.Uses += vorig.Uses |
311 | 311 | vorig.Link = v |
312 | } else if v := s.Parent.findUndeclared(vorig.Data); v != nil { | |
313 | // check if variable is already used before in the current or lower scopes | |
312 | } else if v := s.Parent.findDeclared(vorig.Data, false); v != nil { | |
313 | // check if variable has been declared in this scope | |
314 | 314 | v.Uses += vorig.Uses |
315 | 315 | vorig.Link = v |
316 | 316 | } else { |