Project

General

Profile

Actions

Feature #7393

closed

Fix array behaviour when it is used as a queue: github#174

Added by zzak (zzak _) almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
[ruby-core:49554]

Description

=begin
from github:
https://github.com/ruby/ruby/pull/174

When array is used intensively as a queue (ie repeated push/shift calls), then its performance degrades very quickly with array's size (especially when almost every shift is followed be push), cause each push which is called after shift leads to allocation of new memory space and copying all items to.

This pull request fixes it in following way:

  • reuse shared array's storage when array is a single owner of shared array.
  • try to push items directly into shared array when array is a single owner of shared array
  • try to unshift items directly into shared array when array is a single owner (and allocate room for futher unshifts)
    =end

Files

array_as_queue.patch (9.69 KB) array_as_queue.patch zzak (zzak _), 11/19/2012 12:18 PM

Updated by nagachika (Tomoyuki Chikanaga) almost 12 years ago

Hi,

I think the pull request was merged to trunk as r37581-r37584.

Updated by kosaki (Motohiro KOSAKI) almost 12 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0