Refactor CFrame.new constructors to use a match on args.len() #102
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.
Closes #100.
This PR changes the
CFrame.new
constructors implementation to use a match on the length of the argument list, with no other changes to behavior. This removes Lune's reliance on execution order forCFrame.new
argument evaluationAdditionally, this change makes it so we only have to clone the argument list a maximum of one time. I think there's still an opportunity to refactor further so we don't have to clone at all, but I didn't want to spend any more time on it, and it's already an improvement
I couldn't really add a test for this (something like
assertEq(CFrame.new(1, 2, 3, 1, 0, 0, 0, 1, 0, 0, 0, 1), CFrame.new(1, 2, 3))
) since the 12-arg constructor is row-major - will need to do #99 to get this kind of test to pass