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

Variables added to prototype in inherit call #406

Closed
jessegreenberg opened this issue Feb 22, 2018 · 4 comments
Closed

Variables added to prototype in inherit call #406

jessegreenberg opened this issue Feb 22, 2018 · 4 comments
Assignees

Comments

@jessegreenberg
Copy link
Contributor

From #398 -
I noticed that the curvatureTemp2 and cuvatureTemp are used to track cuvature of the track at the skater's location. They are added to the prototype in the inherit call of EnergySkateParkBasicsModel.js. I haven't seen variables declared here before. @samreid is there an allocation benefit of defining these variables here? Could they be moved to the constructor?

@jessegreenberg
Copy link
Contributor Author

Also, curvatureTemp looks like:

    curvatureTemp: { r: 1, x: 0, y: 0 },

Are the initial values important?

@samreid
Copy link
Member

samreid commented Feb 23, 2018

curvatureTemp and curvatureTemp2 are not instance variables and should not be moved to the constructor--it seems they should be moved closer to this line:

  // Reuse empty object for creating SkaterStates to avoid allocations
  var EMPTY_OBJECT = {};

Since they have similar intent. The initial values are not important--these curvatureTemp objects were introduced to prevent memory allocations to get acceptable performance on iPad.

@samreid samreid assigned jessegreenberg and unassigned samreid Feb 23, 2018
@jessegreenberg
Copy link
Contributor Author

Thanks, I understand now. Sounds good.

@jessegreenberg
Copy link
Contributor Author

This was done in ESP, closing this issue.

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

No branches or pull requests

2 participants