Comment by _3u10

Comment by _3u10 3 days ago

7 replies

It’s just two pointers the current place to write and the current place to read, escapes are always more characters than they represent so there’s no danger of overwriting the read pointer. If you support compression this can become somewhat of and issue but you simply support a max block size which is usually defined by the compression algorithm anyway.

Ygg2 3 days ago

If you have a place to write, then it's not zero allocation. You did an allocation.

And usually if you want maximum performance, buffered read is the way to go, which means you need a write slab allocation.

  • lelanthran 3 days ago

    > If you have a place to write, then it's not zero allocation. You did an allocation.

    Where did that allocation happen? You can write into the buffer you're reading from, because the replacement data is shorter than the original data.

    • Ygg2 2 days ago

      You have a read buffer and somewhere where you have to write to.

      Even if we pretend that the read buffer is not allocating (plausible), you will have to allocate for the write source for the general case (think GiB or TiB of XML or JSON).

      • lelanthran 2 days ago

        > You have a read buffer and somewhere where you have to write to.

        The "somewhere you have to write to" is the same buffer you are reading from.