Skip to content

Commit

Permalink
Some code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kenlyon committed Oct 24, 2024
1 parent 9fc2663 commit d2301a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions Jint/Native/JsSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class JsSet : ObjectInstance
{
}

public JsSet(Engine engine, OrderedSet<JsValue> set) : base(engine)
internal JsSet(Engine engine, OrderedSet<JsValue> set) : base(engine)
{
_set = set;
_prototype = _engine.Realm.Intrinsics.Set.PrototypeObject;
Expand Down Expand Up @@ -49,15 +49,13 @@ protected override bool TryGetProperty(JsValue property, [NotNullWhen(true)] out

public void Add(JsValue value) => _set.Add(value);

public void Remove(JsValue value) => _set.Remove(value);

public void Clear() => _set.Clear();

public bool Has(JsValue key) => _set.Contains(key);

public bool SetDelete(JsValue key) => _set.Remove(key);

public void ForEach(ICallable callable, JsValue thisArg)
internal void ForEach(ICallable callable, JsValue thisArg)
{
var args = _engine._jsValueArrayPool.RentArray(3);
args[2] = this;
Expand All @@ -73,7 +71,7 @@ public void ForEach(ICallable callable, JsValue thisArg)
_engine._jsValueArrayPool.ReturnArray(args);
}

public ObjectInstance Entries() => _engine.Realm.Intrinsics.SetIteratorPrototype.ConstructEntryIterator(this);
internal ObjectInstance Entries() => _engine.Realm.Intrinsics.SetIteratorPrototype.ConstructEntryIterator(this);

public ObjectInstance Values() => _engine.Realm.Intrinsics.SetIteratorPrototype.ConstructValueIterator(this);
internal ObjectInstance Values() => _engine.Realm.Intrinsics.SetIteratorPrototype.ConstructValueIterator(this);
}
6 changes: 3 additions & 3 deletions Jint/Native/Set/SetPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private JsSet Difference(JsValue thisObject, JsValue[] arguments)
var inOther = TypeConverter.ToBoolean(otherRec.Has.Call(otherRec.Set, args));
if (inOther)
{
resultSetData.Remove(e);
resultSetData.SetDelete(e);
index--;
}
}
Expand All @@ -144,7 +144,7 @@ private JsSet Difference(JsValue thisObject, JsValue[] arguments)
nextValue = JsNumber.PositiveZero;
}

resultSetData.Remove(nextValue);
resultSetData.SetDelete(nextValue);
}

return resultSetData;
Expand Down Expand Up @@ -308,7 +308,7 @@ private JsSet SymmetricDifference(JsValue thisObject, JsValue[] arguments)
{
if (inResult)
{
resultSetData.Remove(nextValue);
resultSetData.SetDelete(nextValue);
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion Jint/Runtime/OrderedSet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Jint.Runtime;

public sealed class OrderedSet<T>
internal sealed class OrderedSet<T>
{
internal List<T> _list;
internal HashSet<T> _set;
Expand Down

0 comments on commit d2301a7

Please sign in to comment.