3 ms·
> amortized growth of a large buffer, which will happen max log n times in a buffer of size n You can do better than log if you care to; just grow the buffer m
by moonchild 5y ago
> amortized growth of a large buffer, which will happen max log n times in a buffer of size n
You can do better than log if you care to; just grow the buffer more quickly. It's just that exponential growth tends to work pretty well (and, notably, amortizes the overhead of copying such that it is O(1)). Also: people tend to take breaks when typing, so you can asynchronously try to grow the buffer when it is close to full.