ruby/ruby — pull request #150 by gregolsen (2012-07-26 06:04:48+00:00)
Title: Enumerator::Lazy optimized using Procs chaining

All methods of `Enumerator::Lazy` except `#cycle`, `#zip` and `#flat_map` optimized by using Procs chaining. Unoptimized methods are still use enumerators chaining and can be converted to Procs chaining later on.

I believe it's an extensible way to do that (as requested by Nobuyoshi Nakada).
Follow the discussion here: http://bugs.ruby-lang.org/issues/6183

All tests pass along with `#inspect` test and hybrid chaining test (when optimized and unoptimized methods chained together) added by patch.

Benchmark results:

```
======================Lazy#map
user system total real
Trunk 1.330000 0.000000 1.330000 ( 1.332653)
Optimized 0.770000 0.000000 0.770000 ( 0.779608)
======================Lazy#select
user system total real
Trunk 1.240000 0.000000 1.240000 ( 1.238195)
Optimized 0.740000 0.000000 0.740000 ( 0.739532)
======================Lazy#grep
user system total real
Trunk 1.500000 0.000000 1.500000 ( 1.506823)
Optimized 0.740000 0.000000 0.740000 ( 0.741049)
======================Lazy#take_while
user system total real
Trunk 1.250000 0.000000 1.250000 ( 1.249061)
Optimized 0.730000 0.000000 0.730000 ( 0.738524)
======================Lazy#drop_while
user system total real
Trunk 1.020000 0.000000 1.020000 ( 1.022606)
Optimized 0.410000 0.000000 0.410000 ( 0.414222)
======================Lazy#reject
user system total real
Trunk 1.270000 0.010000 1.280000 ( 1.293468)
Optimized 0.740000 0.010000 0.750000 ( 0.750853)
======================Lazy#drop
user system total real
Trunk 4.080000 0.000000 4.080000 ( 4.086188)
Optimized 1.510000 0.000000 1.510000 ( 1.517811)
======================Lazy#take
user system total real
Trunk 0.540000 0.000000 0.540000 ( 0.550599)
Optimized 0.390000 0.000000 0.390000 ( 0.383634)
```