diff options
| author | Jack Nagel | 2013-04-14 18:20:09 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-04-14 18:32:48 -0500 |
| commit | 04b400ef9a0837806680b04f9d5924101c680371 (patch) | |
| tree | 54cf1d134ae40ee146bd4f31571c5314096faa30 | |
| parent | 90b70fd8a111afe450b5f9ec74b997a5efa0586d (diff) | |
| download | homebrew-04b400ef9a0837806680b04f9d5924101c680371.tar.bz2 | |
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)
| -rw-r--r-- | Library/Homebrew/bottles.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 32b6f8471..159654c48 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -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 |
