From ac9a6031f370dbc480f4adb158389d9dc877e0b5 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Mon, 28 Mar 2016 08:50:30 -0700
Subject: [PATCH] Sprinkle constants here and there

---
 src/core/transport/chttp2/frame_data.c          | 5 +++--
 src/core/transport/chttp2/frame_rst_stream.c    | 5 +++--
 src/core/transport/chttp2/frame_window_update.c | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/core/transport/chttp2/frame_data.c b/src/core/transport/chttp2/frame_data.c
index 64c0b482ad..39ec084e9a 100644
--- a/src/core/transport/chttp2/frame_data.c
+++ b/src/core/transport/chttp2/frame_data.c
@@ -117,8 +117,9 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
                              gpr_slice_buffer *outbuf) {
   gpr_slice hdr;
   uint8_t *p;
+  static const size_t header_size = 9;
 
-  hdr = gpr_slice_malloc(9);
+  hdr = gpr_slice_malloc(header_size);
   p = GPR_SLICE_START_PTR(hdr);
   GPR_ASSERT(write_bytes < (1 << 24));
   *p++ = (uint8_t)(write_bytes >> 16);
@@ -134,7 +135,7 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
 
   gpr_slice_buffer_move_first(inbuf, write_bytes, outbuf);
 
-  stats->framing_bytes += 9;
+  stats->framing_bytes += header_size;
   stats->data_bytes += write_bytes;
 }
 
diff --git a/src/core/transport/chttp2/frame_rst_stream.c b/src/core/transport/chttp2/frame_rst_stream.c
index a5655ce79b..f87d2e58dd 100644
--- a/src/core/transport/chttp2/frame_rst_stream.c
+++ b/src/core/transport/chttp2/frame_rst_stream.c
@@ -40,8 +40,9 @@
 
 gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
                                         grpc_transport_one_way_stats *stats) {
-  gpr_slice slice = gpr_slice_malloc(13);
-  stats->framing_bytes += 13;
+  static const size_t frame_size = 13;
+  gpr_slice slice = gpr_slice_malloc(frame_size);
+  stats->framing_bytes += frame_size;
   uint8_t *p = GPR_SLICE_START_PTR(slice);
 
   *p++ = 0;
diff --git a/src/core/transport/chttp2/frame_window_update.c b/src/core/transport/chttp2/frame_window_update.c
index f7ae6003c8..301e6a10de 100644
--- a/src/core/transport/chttp2/frame_window_update.c
+++ b/src/core/transport/chttp2/frame_window_update.c
@@ -38,8 +38,9 @@
 
 gpr_slice grpc_chttp2_window_update_create(
     uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) {
-  gpr_slice slice = gpr_slice_malloc(13);
-  stats->header_bytes += 13;
+  static const size_t frame_size = 13;
+  gpr_slice slice = gpr_slice_malloc(frame_size);
+  stats->header_bytes += frame_size;
   uint8_t *p = GPR_SLICE_START_PTR(slice);
 
   GPR_ASSERT(window_update);
-- 
GitLab