Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds reference to the instance name to symbol #34

Merged
merged 2 commits into from
Feb 17, 2017
Merged

Conversation

bigtimebuddy
Copy link
Member

@bigtimebuddy bigtimebuddy commented Feb 16, 2017

Changed

Modified the instance name setting to allow the name of the symbol to be set reflectively. This approach also accomodates other non alpha-numeric names (e.g., hyphens).

Old Approach

Old approach were instance names were set inline when instantiating the new instance.

var instance1 = this.example = new lib.Symbol_1()
    .setTransform(150.45, 85.7);

Minified

a=this.example=(new e.Symbol_1).t(150.45,85.7);

New Approach

Here the instance name is declared as a string and the minified code is slightly longer.

var instance1 = new lib.Symbol_1()
    .setTransform(150.45, 85.7);
this[instance1.name = "example"] = instance1;

Minified

a=(new e.Symbol_1).t(150.45,85.7);this[a.name="example"]=a

Copy link
Collaborator

@andrewstart andrewstart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. As devil's advocate; in the interest of avoiding V8 hidden classes, would we instead want to have all Containers have a childrenByName map where we set this child, rather than the parent getting a new property for each child? I realize that it is more verbose and generally less friendly, but could have beneficial performance outcomes.

@bigtimebuddy
Copy link
Member Author

@andrewstart I see what you're saying there. That most likely would be a breaking change, so probably a v2 approach to instance names. Another approach might be to have an instances property instead of a method. This would not create new properties on the class and would be a little easier to access instances, for instance clip.instances.example

@andrewstart
Copy link
Collaborator

I hadn't meant a method, but instances is a better name anyway.

@bigtimebuddy bigtimebuddy merged commit 0d3dbb1 into master Feb 17, 2017
@bigtimebuddy bigtimebuddy deleted the instance-name branch February 17, 2017 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants