-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat(array): add to_reversed prototype method #446
feat(array): add to_reversed prototype method #446
Conversation
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.
Great job! Few minor issues, but all in all this is perfectly good to go.
Adding a fast path is possible, but requires a tad bit more involved work that touches on the Array's backing "elements heap vectors". This isn't too-too bad but requires a bit of work. I'll be happy to help if you want to take a stab at it.
nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs
Outdated
Show resolved
Hide resolved
nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs
Outdated
Show resolved
Hide resolved
nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs
Show resolved
Hide resolved
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.
Some errors leaked in but overall this is indeed exactly how the fast path should work. Nice work! <3
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.
LGTM, and thank you for the work and for the patience! Great stuff, and the shallow clone helper function will be of great help in the future with other toCloned
array prototype methods.
I left a few minor things that could be changed, the comment thing being most important. But otherwise this looks very much good to go! <3
5833071
to
ec4f916
Compare
Looks all good to me! Thank you very much, and sorry for the delay in reviewing! <3 |
Hey!
This PR adds
Array.prototype.to_reversed
method.I tried to add a fast path similar to
Array.prototype.reverse
method but I wasn't able to figure out how to clone the array in order to not mutate the original array order. At least by doingarray.clone()
didn't work (it mutated the original array as well) and then the converting it to slice and back to an array triggers some issues between&[Option<Value>]
and&[Value]
that I couldn't find an easy fix - if we should add the fast path anyway, ideas are welcomed on how to implement it 🙏