-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New DeepClone code snippet #847
Conversation
I've made a bit more documented of a code snippet to help scripters navigate their way through it, considering not everyone viewing would be experienced. This take on the deep clone snippet also gives a faster result, meaning the code is ran faster and you get your value returned faster. OLD: **0.0000051** NEW: **0.0000034** The difference may be small but definitely in some cases noticeable and useful. This is due to the usage of the generalized iterator. Also simplifying the code with ternary operators. But, I believe my take on this new snippet would definitely be faster, and also educate other scripters better, even spiking their curiosity in code simplification if not familiar with ternary operators. All in short, I believe It's a great take.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @EnumEnv, thanks so much for helping improve the Roblox creator documentation! Our technical writing team will review your pull request soon. In the meantime, please ensure you've read through the README.md, contribution guidelines, and style recommendations.
table.clone would like to have a word with you about performance (unsure if its faster since you still have to iterate the table for tables) |
Hi @EnumEnv , in your version, where does |
@metatablecat The reason the 'your solution' one is slower is because you used "pairs", which I initially didn't use at all, I used the generalized iteration. So, that's the reason of it slowing down. Generally it should be faster. |
Waiting on another review. Tested everything and re-benchmarked. |
@EnumEnv looks good now! I just did minor edits to the comment lines (no ending periods as per our typical style, etc.) |
Changes
I've made a bit more documented of a code snippet to help scripters navigate their way through it, considering not everyone viewing would be experienced. This take on the deep clone snippet also gives a faster result, meaning the code is ran faster and you get your value returned faster.
OLD: 0.0000051 (os.clock)
NEW: 0.0000034 (os.clock)
The difference may be small but definitely in some cases noticeable and useful. This is due to the usage of the generalized iterator. Also simplifying the code with ternary operators. But, I believe my take on this new snippet would definitely be faster, and also educate other scripters better, even spiking their curiosity in code simplification if not familiar with ternary operators. All in short, I believe It's a great take.
https://create.roblox.com/docs/luau/tables#deep-clones
https://devforum.roblox.com/t/ternary-like-operation-in-lua/834254
Checks
By submitting your pull request for review, you agree to the following: