5 ms·
this.img.src = this.img.src.replace(/Fish[a-zA-Z0-9]\./, "Fish"+this.direction+".") It looks like this line is executed on every frame for all fish in the leve
by mstange 14y ago
this.img.src = this.img.src.replace(/Fish[a-zA-Z0-9]\./, "Fish"+this.direction+".")
It looks like this line is executed on every frame for all fish in the level. For Firefox users who have the Ghostery addon installed, this makes things rather slow because every setting of the src property invokes Ghostery to check whether or not it wants to block the image load.
Granted, that should be another reason for me to uninstall Ghostery, but I wanted to let you know.
- fiblye 14y agoThat was the first NPC I ever made and it's evidence of my dumb code from back then. Guess I forgot to change it.
- kami8845 14y agohow did you figure out that this LOC slowed things down?
- mstange 14y agoUsing the new Firefox profiler [0], which isn't quite ready for public consumption yet but already very helpful: 1. Download Firefox Nightly [1] 2. Install the profiler addon [2] 3. Play the game 4. Press Cmd+Shift+O to open a profile of the most recent few seconds 5. Wade through the tree until you find nsIDOMHTMLImageElement_SetSrc, which is called by <Anonymous>() @ CompletedEnemies.js:2460. This function contains only one line which assigns to the src property of an image, and that's the line I pasted. [0] https://developer.mozilla.org/en-US/docs/Performance/Profiling_with_the_Built-in_Profiler https://developer.mozilla.org/en-US/docs/Performance/Profili... [1] http://nightly.mozilla.org/ http://nightly.mozilla.org/ [2] https://addons.mozilla.org/en-us/firefox/addon/gecko-profiler/ https://addons.mozilla.org/en-us/firefox/addon/gecko-profile...
- kami8845 14y agoI knew I was gonna get something good when I asked that question, thank you!