diff options
author | Craig Tiller <ctiller@google.com> | 2016-04-23 13:31:34 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-04-23 13:31:34 -0700 |
commit | 0ca01ed80de6b9e698c004534957bca31f70f2c2 (patch) | |
tree | 6ffb2b04543fcb206eff72f4436558c068038104 /src/core/ext | |
parent | c2c0f53e4eb7fe8906df55d984fdb36dc58b649f (diff) | |
parent | ab8b9f51437ab7502b09bed22b7fc1a265016e44 (diff) |
Expand corpus
Diffstat (limited to 'src/core/ext')
-rw-r--r-- | src/core/ext/transport/chttp2/transport/bin_encoder.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.c index db68e750ac..1b43c28be1 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.c +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.c @@ -194,9 +194,13 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) { /* encode full triplets */ for (i = 0; i < input_triplets; i++) { - enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4) | (in[1] >> 4)); - enc_add2(&out, (uint8_t)((in[1] & 0xf) << 2) | (in[2] >> 6), - (uint8_t)(in[2] & 0x3f)); + const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4); + const uint8_t high_to_low = in[1] >> 4; + enc_add2(&out, in[0] >> 2, low_to_high | high_to_low); + + const uint8_t a = (uint8_t)((in[1] & 0xf) << 2); + const uint8_t b = (in[2] >> 6); + enc_add2(&out, a | b, in[2] & 0x3f); in += 3; } @@ -208,12 +212,14 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) { enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4)); in += 1; break; - case 2: - enc_add2(&out, in[0] >> 2, - (uint8_t)((in[0] & 0x3) << 4) | (uint8_t)(in[1] >> 4)); + case 2: { + const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4); + const uint8_t high_to_low = in[1] >> 4; + enc_add2(&out, in[0] >> 2, low_to_high | high_to_low); enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2)); in += 2; break; + } } if (out.temp_length) { |