Open swankjesse opened 5 years ago
There are a couple choice with a function like this.
Location
buildByteString {...}
- single locationByteString
companion function ByteString.build {...}
- expect/actual and all that fun but scopedConversion
buffer.readByteString()
- results in copybuffer.snapshot()
- SegmentedByteString
and everything that comes with itI'm leaning towards ByteString.build {...}
and buffer.readByteString()
. Could add ByteString.buildSnapshot {...}
if we wanted to use buffer.snapshot()
.
I think we should have a thoughtful policy on when to do snapshots. Maybe everywhere the byte string is at least size X, where X is 2 segments or something?
Are you talking about enhancing readByteString()
to return snapshots when the byte count is above some threshold? Or only for this specific builder function? I would make this enhancement to readByteString()
so everyone benefits.
Exactly right right place for the enhancements!
This would be handy in ~4 places in OkHttp, possibly more elsewhere.