google-cloud-cpp icon indicating copy to clipboard operation
google-cloud-cpp copied to clipboard

REST: refactor moving bytes between buffers

Open scotthart opened this issue 4 years ago • 1 comments

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 avatar Jan 21 '22 22:01 scotthart

@scotthart thinks this is done. Double checking

coryan avatar Jun 30 '22 18:06 coryan

devbww already is looking into this.

coryan avatar Dec 21 '22 19:12 coryan

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.

devbww avatar Dec 29 '22 18:12 devbww