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

Unified Diff: net/http/http_request_headers.cc

Issue 1549063003: Don't unnecessarily copy strings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add WhitespaceHandling and SplitResult to SplitStringPieceUsingSubstr Created 4 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/strings/string_split_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_request_headers.cc
diff --git a/net/http/http_request_headers.cc b/net/http/http_request_headers.cc
index c2eee59af95f8408a9d11ad774986e302270175b..62e4dd7013d99c477391ced11d0c141a840d8ed6 100644
--- a/net/http/http_request_headers.cc
+++ b/net/http/http_request_headers.cc
@@ -154,15 +154,9 @@ void HttpRequestHeaders::AddHeaderFromString(
void HttpRequestHeaders::AddHeadersFromString(
const base::StringPiece& headers) {
- // TODO(willchan): Consider adding more StringPiece support in string_util.h
- // to eliminate copies.
- std::vector<std::string> header_line_vector;
- base::SplitStringUsingSubstr(headers.as_string(), "\r\n",
- &header_line_vector);
- for (std::vector<std::string>::const_iterator it = header_line_vector.begin();
- it != header_line_vector.end(); ++it) {
- if (!it->empty())
- AddHeaderFromString(*it);
+ for (const base::StringPiece& header : base::SplitStringPieceUsingSubstr(
+ headers, "\r\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
+ AddHeaderFromString(header);
}
}
« no previous file with comments | « base/strings/string_split_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698