Skip to content

Commit 9d7ce47

Browse files
sodirayRay Epps
and
Ray Epps
authored
Fix group performance: don't reduce + spread (#169)
Co-authored-by: Ray Epps <[email protected]>
1 parent ed21a8b commit 9d7ce47

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

Diff for: cdn/radash.esm.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const group = (array, getGroupId) => {
22
return array.reduce((acc, item) => {
33
const groupId = getGroupId(item);
4-
const groupList = acc[groupId] ?? [];
5-
return { ...acc, [groupId]: [...groupList, item] };
4+
if (!acc[groupId])
5+
acc[groupId] = [];
6+
acc[groupId].push(item);
7+
return acc;
68
}, {});
79
};
810
const boil = (array, compareFunc) => {

Diff for: cdn/radash.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ var radash = (function (exports) {
44
const group = (array, getGroupId) => {
55
return array.reduce((acc, item) => {
66
const groupId = getGroupId(item);
7-
const groupList = acc[groupId] ?? [];
8-
return { ...acc, [groupId]: [...groupList, item] };
7+
if (!acc[groupId])
8+
acc[groupId] = [];
9+
acc[groupId].push(item);
10+
return acc;
911
}, {});
1012
};
1113
const boil = (array, compareFunc) => {

0 commit comments

Comments
 (0)