Skip to content
Snippets Groups Projects
Commit 3c73cc28 authored by Jack Nagel's avatar Jack Nagel
Browse files

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)
parent 2e58fbf2
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment