Skip to content

Commit

Permalink
Remove GWT's Map polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Dec 15, 2024
1 parent c2229e7 commit 3ffae87
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
class InternalHashCodeMap<K, V> implements Iterable<Entry<K, V>> {

private final InternalJsMap<Object> backingMap = InternalJsMapFactory.newJsMap();
private final InternalJsMap<Object> backingMap = new InternalStringMap<>();
private AbstractHashMap<K, V> host;
private int size;

Expand Down
35 changes: 9 additions & 26 deletions user/super/com/google/gwt/emul/java/util/InternalJsMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import jsinterop.annotations.JsType;

@JsType(isNative = true, name = "Map", namespace = JsPackage.GLOBAL)
interface InternalJsMap<V> {
class InternalJsMap<V> {

@JsType(isNative = true, name = "IteratorIterable", namespace = JsPackage.GLOBAL)
interface Iterator<V> {
Expand All @@ -47,31 +47,14 @@ interface IteratorEntry<V> {
default V getValue() { return JsUtils.uncheckedCast(getValueInternal()[1]); }
}

V get(int key);
V get(String key);
void set(int key, V value);
void set(String key, V value);
Iterator<V> entries();

@JsOverlay
default void delete(int key) {
// Calls delete without map.delete in order to be compatible with old browsers where delete is a
// keyword.
DeleteFunction fn = JsUtils.getProperty(this, "delete");
fn.call(this, key);
}

@JsOverlay
default void delete(String key) {
// Calls delete without map.delete in order to be compatible with old browsers where delete is a
// keyword.
DeleteFunction fn = JsUtils.getProperty(this, "delete");
fn.call(this, key);
InternalJsMap() {
}

@JsType(isNative = true, name = "Function", namespace = JsPackage.GLOBAL)
interface DeleteFunction {
void call(InternalJsMap<?> thisArg, String key);
void call(InternalJsMap<?> thisArg, int key);
}
native V get(int key);
native V get(String key);
native void set(int key, V value);
native void set(String key, V value);
native Iterator<V> entries();
native delete(String key);
native delete(int key);
}
168 changes: 0 additions & 168 deletions user/super/com/google/gwt/emul/java/util/InternalJsMapFactory.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class InternalStringMap<K, V> implements Iterable<Entry<K, V>> {

private final InternalJsMap<V> backingMap = InternalJsMapFactory.newJsMap();
private final InternalJsMap<V> backingMap = new InternalStringMap<>();
private AbstractHashMap<K, V> host;
private int size;

Expand Down

0 comments on commit 3ffae87

Please sign in to comment.