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

Refactor CFrame.new constructors to use a match on args.len() #102

Conversation

kennethloeffler
Copy link
Contributor

@kennethloeffler kennethloeffler commented Sep 17, 2023

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 for CFrame.new argument evaluation

Additionally, 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

@filiptibell filiptibell merged commit 67fe1d3 into lune-org:main Sep 17, 2023
@kennethloeffler kennethloeffler deleted the cframe-new-dont-rely-on-execution-order branch September 17, 2023 02:48
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.

It is impossible to use the CFrame.new(x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22) constructor
2 participants