-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Implementing stable sort #809
Conversation
Seems to hang? |
Jint/Native/Array/ArrayOperations.cs
Outdated
@@ -68,6 +70,60 @@ public virtual JsValue[] GetAll(Types elementTypes) | |||
|
|||
public abstract void DeletePropertyOrThrow(ulong index); | |||
|
|||
public IEnumerator<JsValue> GetEnumerator() |
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.
If there's an overload of concrete type public ArrayOperationsIterator GetEnumerator()
then there would be no dispatch overhead like the interfaces have, CLR will find the version by name.
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.
What do you suggest? To implement it in each concrete type and call base.GetEnumerator()
?
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.
I was referring to concrete enumerator method without interface, as seen here:
jint/Jint/Collections/DictionarySlim.cs
Lines 221 to 235 in 1d29ae7
/// <summary> | |
/// Gets an enumerator over the dictionary | |
/// </summary> | |
public Enumerator GetEnumerator() => new Enumerator(this); // avoid boxing | |
/// <summary> | |
/// Gets an enumerator over the dictionary | |
/// </summary> | |
IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator() => | |
new Enumerator(this); | |
/// <summary> | |
/// Gets an enumerator over the dictionary | |
/// </summary> | |
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(this); |
Explicit interface implementations for generic use case and then one of concrete type to avoid boxing (struct via interface).
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.
Updated but this new member is not called, and we need to user OrderBy for a stable sort.
There is a test that must be blocked in an infinite loop/ Haven't identified which one yet. |
@lahma new review please |
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.
Looks good and contained. I think that at some point it would make sense to make the actual ObjectInstance
and ArrayInstance
implement the IEnumerable<JsValue>
, this would open resolution for extension methods too.
Fixes #808