-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Object properties should be stored ordered #1539
Comments
I think this is one of the rare instances where a linked list would solve this optimally. What do you think? |
I'm not sure about a linked list. I'm currently testing out the This blog post from the V8 team covers the topic: https://v8.dev/blog/fast-properties. V8 is of course highly optimized. I think we can skip some of those optimizations for now. I was mainly looking at the |
I thought about |
Ignore what I wrote here before. I think we can just |
I don't know if I understood completely, but wouldn't that leave big memory footprints if you insert a lot of items then delete them? |
Also, those are some good optimizations we could make! Maybe it would be a good idea to open a new discussion with every idea we stumble upon to optimize the engine 😄 |
Yes that would be true. But never mind that; |
If it makes |
Made a little digging and found |
Good idea, let's open a separate discussion :) we can then create some issues for it |
I used |
Describe the bug
String
andSymbol
object properties are currently returned in arbitrary order, because the underlying store is astd::collections::HashMap
. The spec specifies, thatString
andSymbol
properties should be returned in order of property creation e.g. OrdinaryOwnPropertyKeys.Index
properties should be returned in ascending numeric order. We currently achieve this by sorting the properties in theordinary_own_property_keys
function.To Reproduce
This JavaScript code reproduces the issue:
This currently may return
[ "c", "b", "a" ]
.Expected behavior
The above code should always return
[ 'b', 'a', 'c' ]
.We should store the properties in data structures that preserve the expected order, so that we do not have to waste time sorting.
The text was updated successfully, but these errors were encountered: