kevin-montrose / Cesil

Modern CSV (De)Serializer
MIT License
65 stars 3 forks source link

Avoid copying by default when taking the range of a dynamic row #9

Closed kevin-montrose closed 3 years ago

kevin-montrose commented 4 years ago

When you take the range of (ie. someRow[1..3]) of a dynamic row, the underlying data is copied into a new Memory<char>. This is only necessary if the original row is disposed after the subset, and even then it a copy could be optimized away in the common case where Options.DynamicRowDisposal is OnReaderDispose.

This will probably require introducing either a new kind of dynamic object (like RangedDynamicRow or something), or introducing a notion of a "mode" to DynamicRow.