Skip to content

Commit 91f5e68

Browse files
committed
fix: separate object vs array loop
- was cheeky, but ofc impacted Array performance - trades +24B for 200-600% performance gain
1 parent 4aff569 commit 91f5e68

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/index.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ function toVal(mix) {
22
var k, y, str='';
33
if (mix) {
44
if (typeof mix === 'object') {
5+
if (!!mix.push) {
6+
for (k=0; k < mix.length; k++) {
7+
if (mix[k] && (y = toVal(mix[k]))) {
8+
str && (str += ' ');
9+
str += y;
10+
}
11+
}
12+
} else {
513
for (k in mix) {
6-
if (mix[k] && (y = toVal(!!mix.push ? mix[k] : k))) {
14+
if (mix[k] && (y = toVal(k))) {
715
str && (str += ' ');
816
str += y;
917
}
1018
}
19+
}
1120
} else if (typeof mix !== 'boolean' && !mix.call) {
1221
str && (str += ' ');
1322
str += mix;

0 commit comments

Comments
 (0)