diff options
author | 2018-09-20 14:55:05 -0700 | |
---|---|---|
committer | 2018-09-20 15:56:05 -0700 | |
commit | ae6f620d6c3cb65f0b534b99a3737ea56005bfa9 (patch) | |
tree | a0f439d67fb5f1d04b732aff9d85b4e2ada492a3 /src/core | |
parent | cc7939060460d1b09a7ce0909d3784308fa3091c (diff) |
Add comment to explain obscure performance choice
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ext/transport/chttp2/transport/parsing.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 8ffd4de17c..8e9aa613a6 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -410,6 +410,12 @@ static void on_initial_header(void* tp, grpc_mdelem md) { } if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) { + // We don't use grpc_mdelem_eq here to avoid executing additional + // instructions. The reasoning is if the payload is not equal, we already + // know that the metadata elements are not equal because the md is + // confirmed to be static. If we had used grpc_mdelem_eq here, then if the + // payloads are not equal, grpc_mdelem_eq executes more instructions to + // determine if they're equal or not. if (md.payload == GRPC_MDELEM_GRPC_STATUS_1.payload || md.payload == GRPC_MDELEM_GRPC_STATUS_2.payload) { s->seen_error = true; @@ -500,6 +506,12 @@ static void on_trailing_header(void* tp, grpc_mdelem md) { } if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) { + // We don't use grpc_mdelem_eq here to avoid executing additional + // instructions. The reasoning is if the payload is not equal, we already + // know that the metadata elements are not equal because the md is + // confirmed to be static. If we had used grpc_mdelem_eq here, then if the + // payloads are not equal, grpc_mdelem_eq executes more instructions to + // determine if they're equal or not. if (md.payload == GRPC_MDELEM_GRPC_STATUS_1.payload || md.payload == GRPC_MDELEM_GRPC_STATUS_2.payload) { s->seen_error = true; |