Skip to content

Commit 0892a84

Browse files
committed
perf(classnames): use arguments instead spread
1 parent b749948 commit 0892a84

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/classnames/classnames.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
*
1212
* @param strings classNames strings
1313
*/
14-
export function classnames(...strings: Array<string | undefined>) {
14+
export function classnames(...strings: Array<string | undefined>): string;
15+
export function classnames() {
1516
let className = '';
1617
const uniqueCache = new Set();
17-
const classNameList = strings.join(' ').split(' ');
18+
// Use arguments instead rest operator for better performance.
19+
const classNameList: Array<string | undefined> = [].slice.call(arguments);
1820

1921
for (const value of classNameList) {
20-
if (value === '' || uniqueCache.has(value)) {
22+
if (value === '' || value === undefined || uniqueCache.has(value)) {
2123
continue;
2224
}
2325

0 commit comments

Comments
 (0)