Closed samreid closed 5 years ago
The same pattern can be applied in Subpath. Not a significant memory savings there but it's nice to have a uniform approach:
Note I've used slightly different names for the emitters. Not sure if that helps us keep them clear/searchable or if it's just more confusing.
Using TinyEmitter in kite sounds great. Would you want to commit those changes to a branch? I wasn't able to figure out yet how to apply those patches.
I committed to a branch. For future reference, WebStorm or IDEA can apply patches via "VCS" --> "Apply Patch From Clipboard". I noticed Shape also employs Events for a similar purpose, but that isn't in the branch.
Converting Shape seems straightforward-- it seem there are only usages in Shape and Path.
@samreid @jonathanolson while this is fresh in the mind and will help WI 2.0, lets make it happen. @samreid would be ideal to be done before publication.
This is one of the last issues marked for Wave Interference 2.0. Let me know if I can do anything to help.
Looks good. Added the Shape/Path conversion, merged to master. @samreid can you verify those changes?
The changes look good. Do you want to keep these error-checking lines?
this.on = function() { throw new Error( 'on' ); };
this.onStatic = function() { throw new Error( 'onStatic' ); };
If I understand correctly, on
and onStatic
are now undefined in Shape, so these would throw errors anyways (as would off and off static). If we are keeping those error checking lines, we should have them check the entire API and apply that pattern in Segment. But I'm presuming they were temporary and should probably be deleted. @jonathanolson thoughts?
But I'm presuming they were temporary and should probably be deleted. @jonathanolson thoughts?
Yup, fixed, thanks for the catch!
Looks great, thanks! Closing.
Discovered in https://github.com/phetsims/wave-interference/issues/399
This patch uses around 1% ~1MB less memory in Wave Interference, by using TinyEmitter instead of Events in Segment.
I'm not too familiar with Kite and I don't know if this patch is sufficient. Also, will this have slightly better performance because it is using TinyEmitter direct calls instead of Events which requires key lookups?
Also tagging for https://github.com/phetsims/wave-interference/issues/408 in case we want to address this before Wave Interference 2.0