Optimization: avoid repeated interpolation in regexp
Benchmark.bm do |b|
b.report("before") do
100_000.times { /(\.#{MacOS.cat}\.bottle\.(\d+\.)?tar\.gz)$/ }
end
b.report("after ") do
100_000.times { /(\.#{MacOS.cat}\.bottle\.(\d+\.)?tar\.gz)$/o }
end
end
user system total real
before 35.400000 0.140000 35.540000 ( 35.619674)
after 0.020000 0.000000 0.020000 ( 0.016662)
This commit is contained in:
parent
2e58fbf260
commit
3c73cc28e0
@ -63,7 +63,7 @@ def bottle_suffix revision=nil
|
||||
end
|
||||
|
||||
def bottle_native_regex
|
||||
/(\.#{MacOS.cat}\.bottle\.(\d+\.)?tar\.gz)$/
|
||||
/(\.#{MacOS.cat}\.bottle\.(\d+\.)?tar\.gz)$/o
|
||||
end
|
||||
|
||||
def bottle_regex
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user