4036dac84d
Motivation: The main use case with Buf.compact is in conjunction with ensureWritable. It turns out we can get a simpler API, and faster methods, by combining those two operations, because it allows us to relax some guarantees and skip some steps in certain cases, which wouldn't be as neat or clean if they were two separate steps. Modification: Add a new Buf.ensureWritable method, which takes an allowCompaction argument. In MemSegBuf, we can just delegate to compact() when applicable. In CompositeBuf, we can sometimes get away with just reorganising the bufs array. Result: We can now do ensureWritable without allocating in some cases, and this can in particular make the operation faster for CompositeBuf. |
||
---|---|---|
.. | ||
api |