Skip to content

Commit a89c034

Browse files
committed
Optimise Dict.forEachWithKey
1 parent 55d7337 commit a89c034

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/es6/Stdlib_Dict.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function forEach(dict, f) {
1010
}
1111

1212
function forEachWithKey(dict, f) {
13-
Object.entries(dict).forEach(param => f(param[1], param[0]));
13+
Object.keys(dict).forEach(key => f(dict[key], key));
1414
}
1515

1616
function mapValues(dict, f) {

lib/js/Stdlib_Dict.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function forEach(dict, f) {
1010
}
1111

1212
function forEachWithKey(dict, f) {
13-
Object.entries(dict).forEach(param => f(param[1], param[0]));
13+
Object.keys(dict).forEach(key => f(dict[key], key));
1414
}
1515

1616
function mapValues(dict, f) {

runtime/Stdlib_Dict.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let forEach = (dict, f) => {
2929
}
3030

3131
let forEachWithKey = (dict, f) => {
32-
dict->toArray->Stdlib_Array.forEach(((key, value)) => f(value, key))
32+
dict->keysToArray->Stdlib_Array.forEach(key => f(dict->getUnsafe(key), key))
3333
}
3434

3535
let mapValues = (dict, f) => {

0 commit comments

Comments
 (0)