Skip to content

Commit a6d1da5

Browse files
authored
impl(GCS+gRPC): more efficient Cord construction (#12729)
1 parent 9b450c5 commit a6d1da5

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

google/cloud/storage/internal/grpc/buffer_read_object_data.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#include "google/cloud/storage/internal/grpc/buffer_read_object_data.h"
16+
#include "google/cloud/storage/internal/grpc/make_cord.h"
1617
#include <algorithm>
1718

1819
namespace google {
@@ -21,27 +22,26 @@ namespace storage_internal {
2122

2223
std::size_t GrpcBufferReadObjectData::FillBuffer(char* buffer, std::size_t n) {
2324
std::size_t offset = 0;
24-
for (auto v : spill_view_.Chunks()) {
25+
for (auto v : contents_.Chunks()) {
2526
if (offset == n) break;
2627
auto const count = std::min(v.size(), n - offset);
2728
std::copy(v.data(), v.data() + count, buffer + offset);
2829
offset += count;
2930
}
30-
spill_view_ = spill_view_.Subcord(offset, spill_view_.size() - offset);
31+
contents_.RemovePrefix(offset);
3132
return offset;
3233
}
3334

3435
std::size_t GrpcBufferReadObjectData::HandleResponse(char* buffer,
3536
std::size_t n,
3637
std::string contents) {
37-
return HandleResponse(buffer, n, absl::Cord(std::move(contents)));
38+
return HandleResponse(buffer, n, MakeCord(std::move(contents)));
3839
}
3940

4041
std::size_t GrpcBufferReadObjectData::HandleResponse(char* buffer,
4142
std::size_t n,
4243
absl::Cord contents) {
4344
contents_ = std::move(contents);
44-
spill_view_ = contents_;
4545
return FillBuffer(buffer, n);
4646
}
4747

google/cloud/storage/internal/grpc/buffer_read_object_data.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class GrpcBufferReadObjectData {
6565

6666
private:
6767
absl::Cord contents_;
68-
absl::Cord spill_view_;
6968
};
7069

7170
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

0 commit comments

Comments
 (0)