Feature #9952

Optimize object allocations in CSV::Row

Added by avit (Andrew Vit) almost 6 years ago. Updated over 5 years ago.

Target version:


I'm seeing a large number of unnecessary array allocations where CSV zips headers & field values together for each row.

  1. We can reverse the zipped arrays in-place instead of re-allocating dup arrays.
  2. We can completely skip the reverse-zip remapping iteration when the number of headers and fields match (probably the common case).

This tiny patch should eliminate one extra temporary array object for every table cell, and saves some unnecessary looping.


csv-20140618.patch (497 Bytes) csv-20140618.patch Optimization for CSV Row avit (Andrew Vit), 06/18/2014 08:46 AM

Updated by nagachika (Tomoyuki Chikanaga) almost 6 years ago

  • Status changed from Open to Assigned

Updated by Glass_saga (Masaki Matsushita) over 5 years ago

  • Tracker changed from Bug to Feature
  • Assignee changed from JEG2 (James Gray) to Glass_saga (Masaki Matsushita)
  • Target version set to 2.2.0

Updated by Anonymous over 5 years ago

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

Applied in changeset r47663.

  • lib/csv.rb: avoid unnecessary object allocations. patch is from Andrew Vit. [ruby-core:63215] [Feature #9952]

Also available in: Atom PDF