Skip to content

Commit deff09b

Browse files
jalalazimiSukkaWlukeed
authoredDec 29, 2023
chore: cache arguments/array lengths (#26)
* feat: enhance performance * chore: undo Extracting k to the outer level Co-authored-by: Sukka <isukkaw@gmail.com> * Apply suggestions from code review --------- Co-authored-by: Sukka <isukkaw@gmail.com> Co-authored-by: Luke Edwards <luke.edwards05@gmail.com>
1 parent 6e2468e commit deff09b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎src/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ function toVal(mix) {
55
str += mix;
66
} else if (typeof mix === 'object') {
77
if (Array.isArray(mix)) {
8-
for (k=0; k < mix.length; k++) {
8+
var len=mix.length;
9+
for (k=0; k < len; k++) {
910
if (mix[k]) {
1011
if (y = toVal(mix[k])) {
1112
str && (str += ' ');
@@ -27,9 +28,9 @@ function toVal(mix) {
2728
}
2829

2930
export function clsx() {
30-
var i=0, tmp, x, str='';
31-
while (i < arguments.length) {
32-
if (tmp = arguments[i++]) {
31+
var i=0, tmp, x, str='', len=arguments.length;
32+
for (; i < len; i++) {
33+
if (tmp = arguments[i]) {
3334
if (x = toVal(tmp)) {
3435
str && (str += ' ');
3536
str += x

0 commit comments

Comments
 (0)
Please sign in to comment.