aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpcpp
diff options
context:
space:
mode:
authorGravatar Soheil Hassas Yeganeh <soheil@google.com>2018-09-25 17:50:45 -0400
committerGravatar Soheil Hassas Yeganeh <soheil@google.com>2018-09-25 17:50:45 -0400
commitc1a1d66864a637f06b409b1768bc05a982b28949 (patch)
tree77ae0d58b4e68402e4234150fcc8516db7d4b66f /include/grpcpp
parentccbad108e45afb7c4fb361202cc0bae5ad7e5da2 (diff)
Avoid allocating temporary strings in Channel::CreateCall().
Add `SliceFromArray()` which takes a `char*` instead of `const string&`, to save string allocations for copying from a `char *`. Use the new API to eliminate two string allocations and copies per call for method and host names. release-note: no
Diffstat (limited to 'include/grpcpp')
-rw-r--r--include/grpcpp/impl/codegen/slice.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/grpcpp/impl/codegen/slice.h b/include/grpcpp/impl/codegen/slice.h
index 8966559dc8..9cdca3ab3c 100644
--- a/include/grpcpp/impl/codegen/slice.h
+++ b/include/grpcpp/impl/codegen/slice.h
@@ -138,6 +138,10 @@ inline grpc_slice SliceFromCopiedString(const grpc::string& str) {
str.length());
}
+inline grpc_slice SliceFromArray(const char* arr, size_t len) {
+ return g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, len);
+}
+
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_SLICE_H