google-cloud-cpp
google-cloud-cpp copied to clipboard
REST: refactor moving bytes between buffers
In CurlImpl::WriteToUserBuffer we juggle bytes between 3 different buffers, look to refactor this such that all buffers are represented as absl::Span<char> possibly like:
std::pair<absl::Span<char>, absl::Span<char>> CopyWithSpill(absl::Span<T> destination, absl::Span<T> spill, absl::Span<T> source) { ...}
std::tie(buffer_, spill_) = CopyWithSpill(std::move(buffer_), std::move(spill_), absl::Span<char>(ptr, nmemb * size));
@scotthart thinks this is done. Double checking
devbww already is looking into this.
The libcurl API does not support data buffers owned by the caller. This means there will always be additional copying of the request/response data into/from the library.
That said, #10474 did introduce interfaces much like those in the original comment here, to copy data between the user/cloud-cpp/libcurl buffers.