Matz: This is quite a significant performance improvement and therefore I th=
ink it is worthwhile.

On 30/07/2013, at 20:48, "matz (Yukihiro Matsumoto)" <matz / ruby-lang.org> wr=
ote:

>=20
> Issue #8707 has been updated by matz (Yukihiro Matsumoto).
>=20
> Status changed from Open to Feedback
>=20
> Do we really need it?  What is use-cases?
>=20
> Matz.
>=20
> ----------------------------------------
> Feature #8707: Hash#reverse_each
> https://bugs.ruby-lang.org/issues/8707#change-40769
>=20
> Author: Glass_saga (Masaki Matsushita)
> Status: Feedback
> Priority: Normal
> Assignee:=20
> Category: core
> Target version: current: 2.1.0
>=20
>=20
> Currently, {}.reverse_each calls Enumerable#reverse_each.
> It will make array and its size can be large.
> I made Hash#reverse_each to avoid array creation and performance improveme=
nt.
>=20
> benchmark:
>=20
> require "benchmark"
>=20
> Size =3D 10000
> HASH =3D Hash[*Array.new(Size) {|i| [i, true] }.flatten]
>=20
> Benchmark.bmbm do |x|
>  x.report("Hash#reverse_each") do
>    300.times do
>      HASH.reverse_each {|a, b|}
>    end
>  end
> end
>=20
> result:
>=20
> trunk(r42256):
> Rehearsal -----------------------------------------------------
> Hash#reverse_each   1.210000   0.000000   1.210000 (  1.207964)
> -------------------------------------------- total: 1.210000sec
>=20
>                        user     system      total        real
> Hash#reverse_each   0.950000   0.000000   0.950000 (  0.951069)
>=20
> proposal:=20
> Rehearsal -----------------------------------------------------
> Hash#reverse_each   0.600000   0.000000   0.600000 (  0.600242)
> -------------------------------------------- total: 0.600000sec
>=20
>                        user     system      total        real
> Hash#reverse_each   0.450000   0.000000   0.450000 (  0.459006)
>=20
>=20
> --=20
> http://bugs.ruby-lang.org/
>=20