l3mpire / lemverse

The first-ever coworking metaverse
https://app.lemverse.com
GNU Affero General Public License v3.0
148 stars 40 forks source link

Optimize tileset edition #194

Closed xsyann closed 1 year ago

xsyann commented 1 year ago

When selectedTileset() is called in an handlebars template, a new cursor with an observer is created for each call (e.g tile2domX, tile2domY, etc), meaning that, for a large template, when a tileset is edited (for collision or layering), Meteor does literally thousands of local Minimongo updates of the tileset document copies, taking several seconds to perform.

This part might need a bigger refactoring but in the meanwhile I suggest this small optimization which allows to create a new observer only when the selected tileset changes.

Donorhan commented 1 year ago

Well done! Indeed this code is very old and not optimized so this improvement is welcome 🙏🏻