Merge pull request #18927 from soheilhy/transport-error

Add a fast path in grpc_error_get_status() for GRPC_ERROR_NONE.
reviewable/pr18931/r1
Soheil Hassas Yeganeh 6 years ago committed by GitHub
commit e26af33726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/core/lib/transport/error_utils.cc

@ -48,6 +48,18 @@ void grpc_error_get_status(grpc_error* error, grpc_millis deadline,
grpc_status_code* code, grpc_slice* slice,
grpc_http2_error_code* http_error,
const char** error_string) {
// Fast path: We expect no error.
if (GPR_LIKELY(error == GRPC_ERROR_NONE)) {
if (code != nullptr) *code = GRPC_STATUS_OK;
if (slice != nullptr) {
grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, slice);
}
if (http_error != nullptr) {
*http_error = GRPC_HTTP2_NO_ERROR;
}
return;
}
// Start with the parent error and recurse through the tree of children
// until we find the first one that has a status code.
grpc_error* found_error =

Loading…
Cancel
Save