sink
sink copied to clipboard
Optimization: use ropes under the hood
The C implementation of strings is pretty dumb and straight forward (and slow).
We should probably implement a form of rope under the hood. Notice that node.js's v8 already does in some form, because ./perf/cat.sink runs significantly faster in the JS implementation.
See: https://en.wikipedia.org/wiki/Rope_(data_structure)
We can likely keep the C API the same, and just use ropes internally, and flatten ropes when sink_caststr is called.
Perhaps another link of interest:
http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=181EEF66EB411F4277C009A1D492CF75?doi=10.1.1.14.9450&rep=rep1&type=pdf