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

Side by Side Diff: net/spdy/spdy_framer.cc

Issue 965773002: Optimize chained string concatenation in SPDY code. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/spdy_http_utils.cc » ('j') | net/spdy/spdy_http_utils.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spdy_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/stats_counters.h" 9 #include "base/metrics/stats_counters.h"
10 #include "base/third_party/valgrind/memcheck.h" 10 #include "base/third_party/valgrind/memcheck.h"
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 } 1332 }
1333 } 1333 }
1334 1334
1335 WriteLengthZ(cookie_length, length_length, kZStandardData, z); 1335 WriteLengthZ(cookie_length, length_length, kZStandardData, z);
1336 for (size_t i = 0; i < cookie_values.size(); i++) { 1336 for (size_t i = 0; i < cookie_values.size(); i++) {
1337 std::string cookie; 1337 std::string cookie;
1338 // Since zlib will only back-reference complete cookies, a cookie that 1338 // Since zlib will only back-reference complete cookies, a cookie that
1339 // is currently last (and so doesn't have a trailing semicolon) won't 1339 // is currently last (and so doesn't have a trailing semicolon) won't
1340 // match if it's later in a non-final position. The same is true of 1340 // match if it's later in a non-final position. The same is true of
1341 // the first cookie. 1341 // the first cookie.
1342 if (i == 0 && cookie_values.size() == 1) { 1342 if (i > 0)
1343 cookie = cookie_values[i].as_string(); 1343 cookie.append(" ");
1344 } else if (i == 0) { 1344 cookie.append(cookie_values[i].as_string());
1345 cookie = cookie_values[i].as_string() + ";"; 1345 if (i < cookie_values.size() - 1)
1346 } else if (i < cookie_values.size() - 1) { 1346 cookie.append(";");
mmenke 2015/03/09 20:21:58 Isn't this the same as: if (i > 0) cookie.appen
1347 cookie = " " + cookie_values[i].as_string() + ";";
1348 } else {
1349 cookie = " " + cookie_values[i].as_string();
1350 }
1351 WriteZ(cookie, kZCookieData, z); 1347 WriteZ(cookie, kZCookieData, z);
1352 } 1348 }
1353 } else if (it->first == "accept" || 1349 } else if (it->first == "accept" ||
1354 it->first == "accept-charset" || 1350 it->first == "accept-charset" ||
1355 it->first == "accept-encoding" || 1351 it->first == "accept-encoding" ||
1356 it->first == "accept-language" || 1352 it->first == "accept-language" ||
1357 it->first == "host" || 1353 it->first == "host" ||
1358 it->first == "version" || 1354 it->first == "version" ||
1359 it->first == "method" || 1355 it->first == "method" ||
1360 it->first == "scheme" || 1356 it->first == "scheme" ||
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 builder->Seek(compressed_size); 3284 builder->Seek(compressed_size);
3289 builder->RewriteLength(*this); 3285 builder->RewriteLength(*this);
3290 3286
3291 pre_compress_bytes.Add(uncompressed_len); 3287 pre_compress_bytes.Add(uncompressed_len);
3292 post_compress_bytes.Add(compressed_size); 3288 post_compress_bytes.Add(compressed_size);
3293 3289
3294 compressed_frames.Increment(); 3290 compressed_frames.Increment();
3295 } 3291 }
3296 3292
3297 } // namespace net 3293 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_http_utils.cc » ('j') | net/spdy/spdy_http_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698