Avoiding Dynamically Expanding Objects
- use static buffer and operate on it with custom methods until static buffer capacity is exhausted; then, switch to dynamically expanding object
First solution has two disadvantages:
- each buffer expansion doubles size of previous already large buffer (time + memory cost)
- data still needs to be copied into object-internal buffer
Second solution requires more complicated recoding compared to previous code examples