Replace JsValue[] arguments with Arguments struct #1135
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just pushing this into queue so it won't get lost. Concept is based on how YantraJS handles arguments.
Idea is to replace
JsValue[] arguments
in used method signatures for call receiver and instead use a custom struct that hides what's the backing way of handling things.Arguments
gives a better abstraction and offers the same indexing andAt()
capabilties.For four or less parameters they are just fields and don't require array handling, this way
JsValueArrayPool
pretty much becomes obsolete. For larger parameter sets (which should be unusual, 4 is largest handled by EcmaScript built-in functions).The code gets simpler, no need for array pooling and performance doesn't change that much - I think it's in margin of error. API is now also cleaner and passing parameters always goes via
Arguments()
constructor and no need to think about array pooling and releasing of items.Things to think, should we also cover
thisObject
in Arguments and make all calls take justCall(in Arguments arguments)
. This would also allow passing more date in the future if needed. Many methods require engine reference which is a reason from them not bestatic
.BREAKING CHANGE.