Skip to content

Commit

Permalink
fix(range): optimize range formatting
Browse files Browse the repository at this point in the history
This speeds bench-subset and bench-satisfies by up to 20%.
  • Loading branch information
jviide committed Jul 13, 2024
1 parent f4083bd commit a9f61b8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions classes/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,19 @@ class Range {
}

format () {
this.range = this.set
.map((comps) => comps.join(' ').trim())
.join('||')
.trim()
this.range = ''
for (let i = 0; i < this.set.length; i++) {
if (i > 0) {
this.range += '||'
}
const comps = this.set[i]
for (let k = 0; k < comps.length; k++) {
if (k > 0) {
this.range += ' '
}
this.range += comps[k].toString().trim()
}
}
return this.range
}

Expand Down

0 comments on commit a9f61b8

Please sign in to comment.