Skip to content

Commit

Permalink
Clean up ES5 implementation of StringMap.keys() (#11895)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobil4sk authored Dec 19, 2024
1 parent f2638f6 commit 2e91b2a
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions std/js/_std/haxe/ds/StringMap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ import haxe.DynamicAccess;
}

public inline function keys():Iterator<String> {
return new StringMapKeyIterator(h);
return new haxe.iterators.ArrayIterator(Object.keys(h));
}

public inline function iterator():Iterator<T> {
Expand Down Expand Up @@ -157,28 +157,6 @@ import haxe.DynamicAccess;
}
}

private class StringMapKeyIterator {
final h:Dynamic;
final keys:Array<String>;
final length:Int;
var current:Int;

public inline function new(h:Dynamic) {
this.h = h;
keys = Object.keys(h);
length = keys.length;
current = 0;
}

public inline function hasNext():Bool {
return current < length;
}

public inline function next():String {
return keys[current++];
}
}

private class StringMapValueIterator<T> {
final h:Dynamic;
final keys:Array<String>;
Expand Down

0 comments on commit 2e91b2a

Please sign in to comment.