TurboWarp / scratch-vm

Scratch VM with a JIT compiler and more features
https://turbowarp.org/
Mozilla Public License 2.0
75 stars 72 forks source link

Optimize getSpriteTargetByName #215

Open GarboMuffin opened 4 months ago

GarboMuffin commented 4 months ago

O(n) right now, can be optimized to a map lookup

7% of runtime in a big project

yuri-kiss commented 4 months ago

So store the name in a map [NAME=>SPRITE]?

FurryR commented 3 months ago

So store the name in a map [NAME=>SPRITE]?

class Runtime {
  // ...
  targetMap: Map<string /** id **/, RenderedTarget>;
};