mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Build the version scanner regexp once
This commit is contained in:
parent
fab77a8cbd
commit
33c99123f2
@ -146,6 +146,15 @@ class Version
|
||||
end
|
||||
end
|
||||
|
||||
SCAN_PATTERN = Regexp.union(
|
||||
AlphaToken::PATTERN,
|
||||
BetaToken::PATTERN,
|
||||
RCToken::PATTERN,
|
||||
PatchToken::PATTERN,
|
||||
NumericToken::PATTERN,
|
||||
StringToken::PATTERN
|
||||
)
|
||||
|
||||
def self.new_with_scheme(value, scheme)
|
||||
if Class === scheme && scheme.ancestors.include?(Version)
|
||||
scheme.new(value)
|
||||
@ -221,16 +230,7 @@ class Version
|
||||
end
|
||||
|
||||
def tokenize
|
||||
@version.scan(
|
||||
Regexp.union(
|
||||
AlphaToken::PATTERN,
|
||||
BetaToken::PATTERN,
|
||||
RCToken::PATTERN,
|
||||
PatchToken::PATTERN,
|
||||
NumericToken::PATTERN,
|
||||
StringToken::PATTERN
|
||||
)
|
||||
).map! do |token|
|
||||
@version.scan(SCAN_PATTERN).map! do |token|
|
||||
case token
|
||||
when /\A#{AlphaToken::PATTERN}\z/o then AlphaToken
|
||||
when /\A#{BetaToken::PATTERN}\z/o then BetaToken
|
||||
|
Loading…
x
Reference in New Issue
Block a user