Backport #8328

r40457 - Hash#shift performance improvement

Added by Charlie Somerville 12 months ago. Updated 10 months ago.

[ruby-core:54588]
Status:Closed
Priority:Normal
Assignee:Usaku NAKAMURA

Description

r40457 contains a patch which significantly improves the performance of Hash#shift.

As it does not change behaviour, it should be backported.

Thanks.

backport_fix_shift.diff Magnifier (3.29 KB) Yura Sokolov, 06/02/2013 08:42 PM

Associated revisions

Revision 41652
Added by Usaku NAKAMURA 10 months ago

[Backport #8328] Patch by funny-falcon

  • benchmark/bmhashshift.rb: add benchmark for Hash#shift

  • hash.c (rbhashshift): use st_shift if hash is not being iterated to
    delete element without iterating the whole hash.

  • hash.c (shift_i): remove function

  • include/ruby/st.h (stshift): add stshift function

  • st.c (st_shift): ditto

History

#1 Updated by Usaku NAKAMURA 11 months ago

  • Status changed from Open to Assigned
  • Assignee set to Usaku NAKAMURA

Sorry for late reply.

trunk is too different from 1.9.3, so I cannot patch r40457 simply.
Please wait more.

#2 Updated by Yura Sokolov 11 months ago

Backported version of "fix Hash#shift" attached.

#3 Updated by Usaku NAKAMURA 10 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r41652.
Charlie, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


[Backport #8328] Patch by funny-falcon

  • benchmark/bmhashshift.rb: add benchmark for Hash#shift

  • hash.c (rbhashshift): use st_shift if hash is not being iterated to
    delete element without iterating the whole hash.

  • hash.c (shift_i): remove function

  • include/ruby/st.h (stshift): add stshift function

  • st.c (st_shift): ditto

Also available in: Atom PDF