File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-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,15 @@ class Range {
190
190
return false
191
191
}
192
192
}
193
+
194
+ function buildMemoKeyFromOptions ( options ) {
195
+ return (
196
+ ( options . includePrerelease ? FLAG_INCLUDE_PRERELEASE : 0 )
197
+ | ( options . loose ? FLAG_LOOSE : 0 )
198
+ | ( options . rtl ? FLAG_RTL : 0 )
199
+ ) + ''
200
+ }
201
+
193
202
module . exports = Range
194
203
195
204
const LRU = require ( 'lru-cache' )
@@ -206,6 +215,7 @@ const {
206
215
tildeTrimReplace,
207
216
caretTrimReplace,
208
217
} = require ( '../internal/re' )
218
+ const { FLAG_INCLUDE_PRERELEASE , FLAG_LOOSE , FLAG_RTL } = require ( '../internal/constants' )
209
219
210
220
const isNullSet = c => c . value === '<0.0.0-0'
211
221
const isAny = c => c . value === ''
Original file line number Diff line number Diff line change @@ -14,4 +14,7 @@ module.exports = {
14
14
MAX_LENGTH ,
15
15
MAX_SAFE_INTEGER ,
16
16
MAX_SAFE_COMPONENT_LENGTH ,
17
+ FLAG_INCLUDE_PRERELEASE : 1 << 1 ,
18
+ FLAG_LOOSE : 1 << 2 ,
19
+ FLAG_RTL : 1 << 3 ,
17
20
}
You can’t perform that action at this time.
0 commit comments