Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: net/spdy/hpack/hpack_decoder.cc

Issue 1354773002: Avoid string construction overhead for lookup-only HpackEntry objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit: return feels weird in a constructor. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/spdy/hpack/hpack_encoder_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/hpack/hpack_decoder.h" 5 #include "net/spdy/hpack/hpack_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 const HpackEntry* entry = header_table_.GetByIndex(index_or_zero); 184 const HpackEntry* entry = header_table_.GetByIndex(index_or_zero);
185 if (entry == NULL) { 185 if (entry == NULL) {
186 return false; 186 return false;
187 } 187 }
188 if (entry->IsStatic()) { 188 if (entry->IsStatic()) {
189 *next_name = entry->name(); 189 *next_name = entry->name();
190 } else { 190 } else {
191 // |entry| could be evicted as part of this insertion. Preemptively copy. 191 // |entry| could be evicted as part of this insertion. Preemptively copy.
192 key_buffer_.assign(entry->name()); 192 key_buffer_.assign(entry->name().data(), entry->name().size());
193 *next_name = key_buffer_; 193 *next_name = key_buffer_;
194 } 194 }
195 return true; 195 return true;
196 } 196 }
197 197
198 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream, 198 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream,
199 bool is_key, 199 bool is_key,
200 StringPiece* output) { 200 StringPiece* output) {
201 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) { 201 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) {
202 string* buffer = is_key ? &key_buffer_ : &value_buffer_; 202 string* buffer = is_key ? &key_buffer_ : &value_buffer_;
203 bool result = input_stream->DecodeNextHuffmanString(huffman_table_, buffer); 203 bool result = input_stream->DecodeNextHuffmanString(huffman_table_, buffer);
204 *output = StringPiece(*buffer); 204 *output = StringPiece(*buffer);
205 return result; 205 return result;
206 } 206 }
207 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { 207 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) {
208 return input_stream->DecodeNextIdentityString(output); 208 return input_stream->DecodeNextIdentityString(output);
209 } 209 }
210 return false; 210 return false;
211 } 211 }
212 212
213 } // namespace net 213 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/hpack/hpack_encoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698