Skip to content

Commit

Permalink
fix: separate object vs array loop
Browse files Browse the repository at this point in the history
- was cheeky, but ofc impacted Array performance
- trades +24B for 200-600% performance gain
  • Loading branch information
lukeed committed Apr 6, 2019
1 parent 4aff569 commit 91f5e68
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ function toVal(mix) {
var k, y, str='';
if (mix) {
if (typeof mix === 'object') {
if (!!mix.push) {
for (k=0; k < mix.length; k++) {
if (mix[k] && (y = toVal(mix[k]))) {
str && (str += ' ');
str += y;
}
}
} else {
for (k in mix) {
if (mix[k] && (y = toVal(!!mix.push ? mix[k] : k))) {
if (mix[k] && (y = toVal(k))) {
str && (str += ' ');
str += y;
}
}
}
} else if (typeof mix !== 'boolean' && !mix.call) {
str && (str += ' ');
str += mix;
Expand Down

0 comments on commit 91f5e68

Please sign in to comment.