aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/client_sync.cc
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-11-03 11:41:19 -0700
committerGravatar Vijay Pai <vpai@google.com>2016-11-04 07:51:24 -0700
commit90102c2bfcf98f842f66567c67cbccbd0ede1d2b (patch)
tree8870307237865adcfdb167b5b98fee44b93cfcb8 /test/cpp/qps/client_sync.cc
parent852c58e8ae64ccd7361ab0bdc36f3297960c9d5b (diff)
Eliminate unnecessary uses of new[]/delete[] that can be replaced
with vector Also start eliminating uses of plain-old delete that are not helpful
Diffstat (limited to 'test/cpp/qps/client_sync.cc')
-rw-r--r--test/cpp/qps/client_sync.cc12
1 files changed, 3 insertions, 9 deletions
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index a88a24d89c..3f402b5c36 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -138,10 +138,7 @@ class SynchronousUnaryClient final : public SynchronousClient {
class SynchronousStreamingClient final : public SynchronousClient {
public:
SynchronousStreamingClient(const ClientConfig& config)
- : SynchronousClient(config) {
- context_ = new grpc::ClientContext[num_threads_];
- stream_ = new std::unique_ptr<
- grpc::ClientReaderWriter<SimpleRequest, SimpleResponse>>[num_threads_];
+ : SynchronousClient(config), context_(num_threads_), stream_(num_threads_) {
for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) {
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]);
@@ -161,8 +158,6 @@ class SynchronousStreamingClient final : public SynchronousClient {
}
}
}
- delete[] stream_;
- delete[] context_;
}
bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override {
@@ -182,9 +177,8 @@ class SynchronousStreamingClient final : public SynchronousClient {
private:
// These are both conceptually std::vector but cannot be for old compilers
// that expect contained classes to support copy constructors
- grpc::ClientContext* context_;
- std::unique_ptr<grpc::ClientReaderWriter<SimpleRequest, SimpleResponse>>*
- stream_;
+ std::vector<grpc::ClientContext> context_;
+ std::vector<std::unique_ptr<grpc::ClientReaderWriter<SimpleRequest, SimpleResponse>>> stream_;
};
std::unique_ptr<Client> CreateSynchronousUnaryClient(