From d837887af6e2f5905cb4309edcd35750c2f3a539 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 4 Jun 2016 16:23:50 +0900 Subject: [PATCH] nghttpx: Avoid copy --- src/shrpx_api_downstream_connection.cc | 2 +- src/shrpx_downstream.cc | 8 ++++---- src/shrpx_http2_upstream.cc | 6 +++--- src/shrpx_spdy_upstream.cc | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/shrpx_api_downstream_connection.cc b/src/shrpx_api_downstream_connection.cc index b6eaca14..2501d9da 100644 --- a/src/shrpx_api_downstream_connection.cc +++ b/src/shrpx_api_downstream_connection.cc @@ -131,7 +131,7 @@ int APIDownstreamConnection::end_upload_data() { config.conn.downstream = std::make_shared(); const auto &downstreamconf = config.conn.downstream; - auto src = get_config()->conn.downstream; + auto &src = get_config()->conn.downstream; downstreamconf->timeout = src->timeout; downstreamconf->connections_per_host = src->connections_per_host; diff --git a/src/shrpx_downstream.cc b/src/shrpx_downstream.cc index c0a1c15e..60ac686d 100644 --- a/src/shrpx_downstream.cc +++ b/src/shrpx_downstream.cc @@ -510,8 +510,8 @@ bool Downstream::request_buf_full() { } if (dconn_) { - auto downstreamconf = worker->get_downstream_config(); - return request_buf_.rleft() >= downstreamconf->request_buffer_size; + auto &downstreamconf = *worker->get_downstream_config(); + return request_buf_.rleft() >= downstreamconf.request_buffer_size; } return false; @@ -604,9 +604,9 @@ bool Downstream::response_buf_full() { if (dconn_) { auto handler = upstream_->get_client_handler(); auto worker = handler->get_worker(); - auto downstreamconf = worker->get_downstream_config(); + auto &downstreamconf = *worker->get_downstream_config(); - return response_buf_.rleft() >= downstreamconf->response_buffer_size; + return response_buf_.rleft() >= downstreamconf.response_buffer_size; } return false; diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 27b0f718..6f7aa393 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -857,13 +857,13 @@ nghttp2_session_callbacks *create_http2_upstream_callbacks() { namespace { size_t downstream_queue_size(Worker *worker) { - auto downstreamconf = worker->get_downstream_config(); + auto &downstreamconf = *worker->get_downstream_config(); if (get_config()->http2_proxy) { - return downstreamconf->connections_per_host; + return downstreamconf.connections_per_host; } - return downstreamconf->connections_per_frontend; + return downstreamconf.connections_per_frontend; } } // namespace diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 2334ef6d..a618a158 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -514,13 +514,13 @@ uint32_t infer_upstream_rst_stream_status_code(uint32_t downstream_error_code) { namespace { size_t downstream_queue_size(Worker *worker) { - auto downstreamconf = worker->get_downstream_config(); + auto &downstreamconf = *worker->get_downstream_config(); if (get_config()->http2_proxy) { - return downstreamconf->connections_per_host; + return downstreamconf.connections_per_host; } - return downstreamconf->connections_per_frontend; + return downstreamconf.connections_per_frontend; } } // namespace