File tree 1 file changed +31
-2
lines changed
1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,8 @@ class Range {
81
81
82
82
// memoize range parsing for performance.
83
83
// this is a very hot path, and fully deterministic.
84
- const memoOpts = Object . keys ( this . options ) . join ( ',' )
85
- const memoKey = `parseRange: ${ memoOpts } : ${ range } `
84
+ const memoOpts = buildMemoKeyFromOptions ( this . options )
85
+ const memoKey = memoOpts + ':' + range
86
86
const cached = cache . get ( memoKey )
87
87
if ( cached ) {
88
88
return cached
@@ -190,6 +190,35 @@ class Range {
190
190
return false
191
191
}
192
192
}
193
+
194
+ function buildMemoKeyFromOptions ( options ) {
195
+ if ( options . includePrerelease === true ) {
196
+ if ( options . loose === true && options . rtl === true ) {
197
+ return '1'
198
+ }
199
+
200
+ if ( options . loose === true ) {
201
+ return '2'
202
+ }
203
+
204
+ if ( options . rtl === true ) {
205
+ return '3'
206
+ }
207
+
208
+ return '4'
209
+ } else if ( options . loose === true ) {
210
+ if ( options . rtl === true ) {
211
+ return '5'
212
+ }
213
+
214
+ return '6'
215
+ } else if ( options . rtl === true ) {
216
+ return '7'
217
+ } else {
218
+ return '8'
219
+ }
220
+ }
221
+
193
222
module . exports = Range
194
223
195
224
const LRU = require ( 'lru-cache' )
You can’t perform that action at this time.
0 commit comments