Skip to content

Commit 7b3de67

Browse files
DmitrySoshnikovBrainMaestro
authored andcommitted
Use toString directly instead of toRegExp->toString as faster alternative (#1)
1 parent 0a133bf commit 7b3de67

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/rules/optimize-regex.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ module.exports = {
4040
return;
4141
}
4242

43-
const optimizedRegex = optimize(value).toRegExp();
43+
const optimizedRegex = optimize(value).toString();
4444

45-
if (value === optimizedRegex.toString()) {
45+
if (value === optimizedRegex) {
4646
return;
4747
}
4848

@@ -54,7 +54,7 @@ module.exports = {
5454
optimized: optimizedRegex,
5555
},
5656
fix(fixer) {
57-
return fixer.replaceText(node, optimizedRegex.toString());
57+
return fixer.replaceText(node, optimizedRegex);
5858
},
5959
});
6060
}

0 commit comments

Comments
 (0)