Skip to content

Commit f93268d

Browse files
committed
refactor(fixer): optimised fixExtraCurlyBrackets
Cf. https://jsbench.me/kwke8dylap/1
1 parent 6958b4b commit f93268d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/fixer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ function fixExtraCurlyBrackets({ start, fixedData, verbose }) {
163163
const fullData = fixedData.join('\n');
164164
let fixedLine = removeLinebreak(fixedData[targetLine]);
165165

166-
const openingCount = [...fullData].filter((c) => c === '{').length;
167-
const closingCount = [...fullData].filter((c) => c === '}').length;
166+
const data = fullData.split('');
167+
const openingCount = data.filter((c) => c === '{').length;
168+
const closingCount = data.filter((c) => c === '}').length;
168169
const bracketDiff = closingCount - openingCount;
169170

170171
for (let i = 0; i < bracketDiff; i++) {

0 commit comments

Comments
 (0)