Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Cache getter property values on BScript class #41

Open
wardlem opened this issue Jan 6, 2019 · 4 comments
Open

Cache getter property values on BScript class #41

wardlem opened this issue Jan 6, 2019 · 4 comments
Labels
optimization Related to making the library more performant

Comments

@wardlem
Copy link
Collaborator

wardlem commented Jan 6, 2019

This prevents having to perform the calculation multiple times. This requires the use of Object.defineProperty.

This requires that a script's tokens are immutable. Consider enforcing this by freezing (a copy of the) the token array and making the Token class's instance properties read-only (unfortunately, there is not a neat syntax for this built into the language).

@wardlem wardlem added the optimization Related to making the library more performant label Jan 6, 2019
@wardlem wardlem added this to the v1.1.0 milestone Jan 6, 2019
@JBaczuk
Copy link
Owner

JBaczuk commented Jan 11, 2019

Would this occur often, normally (having to recalculate multiple times)?

@wardlem
Copy link
Collaborator Author

wardlem commented Feb 10, 2019

Would this occur often, normally (having to recalculate multiple times)?

Maybe. I could see, for example, the scriptType getter property being accessed repeatedly for the same script.

@JBaczuk
Copy link
Owner

JBaczuk commented Feb 14, 2019

Ok can we file this for future optimizations?

@wardlem
Copy link
Collaborator Author

wardlem commented Feb 15, 2019

Ok can we file this for future optimizations?

Yes, that is fine.

@wardlem wardlem removed this from the v1.1.0 milestone Feb 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
optimization Related to making the library more performant
Projects
None yet
Development

No branches or pull requests

2 participants