diff --git a/Jint/Native/Map/MapInstance.cs b/Jint/Native/Map/JsMap.cs similarity index 89% rename from Jint/Native/Map/MapInstance.cs rename to Jint/Native/Map/JsMap.cs index 9dee03d331..546244c98a 100644 --- a/Jint/Native/Map/MapInstance.cs +++ b/Jint/Native/Map/JsMap.cs @@ -1,17 +1,16 @@ using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; using Jint.Native.Object; using Jint.Runtime; using Jint.Runtime.Descriptors; namespace Jint.Native.Map; -internal sealed class MapInstance : ObjectInstance +internal sealed class JsMap : ObjectInstance { private readonly Realm _realm; internal readonly OrderedDictionary _map; - public MapInstance(Engine engine, Realm realm) : base(engine) + public JsMap(Engine engine, Realm realm) : base(engine) { _realm = realm; _map = new OrderedDictionary(SameValueZeroComparer.Instance); @@ -101,10 +100,4 @@ internal ObjectInstance Values() { return _realm.Intrinsics.MapIteratorPrototype.ConstructValueIterator(this); } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal uint GetSize() - { - return (uint) _map.Count; - } } diff --git a/Jint/Native/Map/MapConstructor.cs b/Jint/Native/Map/MapConstructor.cs index bc26e46aef..26d39f334b 100644 --- a/Jint/Native/Map/MapConstructor.cs +++ b/Jint/Native/Map/MapConstructor.cs @@ -62,7 +62,7 @@ public override ObjectInstance Construct(JsValue[] arguments, JsValue newTarget) var map = OrdinaryCreateFromConstructor( newTarget, static intrinsics => intrinsics.Map.PrototypeObject, - static (Engine engine, Realm realm, object? _) => new MapInstance(engine, realm)); + static (Engine engine, Realm realm, object? _) => new JsMap(engine, realm)); if (arguments.Length > 0 && !arguments[0].IsNullOrUndefined()) { @@ -84,7 +84,7 @@ private JsValue GroupBy(JsValue thisObject, JsValue[] arguments) var items = arguments.At(0); var callbackfn = arguments.At(1); var grouping = GroupByHelper.GroupBy(_engine, _realm, items, callbackfn, mapMode: true); - var map = (MapInstance) Construct(_realm.Intrinsics.Map); + var map = (JsMap) Construct(_realm.Intrinsics.Map); foreach (var pair in grouping) { map.MapSet(pair.Key, pair.Value); diff --git a/Jint/Native/Map/MapIteratorPrototype.cs b/Jint/Native/Map/MapIteratorPrototype.cs index c100627dc8..ab34b712ee 100644 --- a/Jint/Native/Map/MapIteratorPrototype.cs +++ b/Jint/Native/Map/MapIteratorPrototype.cs @@ -35,7 +35,7 @@ protected override void Initialize() SetSymbols(symbols); } - internal IteratorInstance ConstructEntryIterator(MapInstance map) + internal IteratorInstance ConstructEntryIterator(JsMap map) { var instance = new MapIterator(Engine, map) { @@ -45,7 +45,7 @@ internal IteratorInstance ConstructEntryIterator(MapInstance map) return instance; } - internal IteratorInstance ConstructKeyIterator(MapInstance map) + internal IteratorInstance ConstructKeyIterator(JsMap map) { var instance = new IteratorInstance.EnumerableIterator(Engine, map._map.Keys) { @@ -55,7 +55,7 @@ internal IteratorInstance ConstructKeyIterator(MapInstance map) return instance; } - internal IteratorInstance ConstructValueIterator(MapInstance map) + internal IteratorInstance ConstructValueIterator(JsMap map) { var instance = new IteratorInstance.EnumerableIterator(Engine, map._map.Values) { @@ -71,7 +71,7 @@ private sealed class MapIterator : IteratorInstance private int _position; - public MapIterator(Engine engine, MapInstance map) : base(engine) + public MapIterator(Engine engine, JsMap map) : base(engine) { _map = map._map; _position = 0; diff --git a/Jint/Native/Map/MapPrototype.cs b/Jint/Native/Map/MapPrototype.cs index f0726243cd..ff77ac3f70 100644 --- a/Jint/Native/Map/MapPrototype.cs +++ b/Jint/Native/Map/MapPrototype.cs @@ -125,9 +125,9 @@ private ObjectInstance Values(JsValue thisObject, JsValue[] arguments) return map.Values(); } - private MapInstance AssertMapInstance(JsValue thisObject) + private JsMap AssertMapInstance(JsValue thisObject) { - if (thisObject is MapInstance map) + if (thisObject is JsMap map) { return map; }