rspec/rspec-mocks — pull request #401 by xaviershay (2013-08-10 03:51:09+00:00)
Title: Improve performance of double creation.

A couple of optimisations that speed up double creation significantly. See individual commits for their contribution details.

Time to create 1000 doubles:

I just cranked away with benchmark and `ruby-prof` for a while, using code like the following:

``` Ruby
n = 1000
Benchmark.bm do |bm|
RSpec::Mocks.setup(self)

(0..9).each do |m|
attrs = m.times.inject({}) {|h, x|
h["method_#{x}"] = x
h
}

bm.report("double") do
n.times do
double(attrs)
end
end
end
end
```

**Notes**

* `caller` location has changed for `expected_from` definition. Pretty sure this isn't a problem.
* "simple stub" is a new concept, I believe it justifies itself in the speed improvement.
* Addresses #193.

R @myronmarston