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

Side by Side Diff: chromeos/system/version_loader.cc

Issue 1284833004: Remove remaining legacy SplitString calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chromeos/system/version_loader.h" 5 #include "chromeos/system/version_loader.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 std::string ParseFirmware(const std::string& contents) { 69 std::string ParseFirmware(const std::string& contents) {
70 // The file contains lines such as: 70 // The file contains lines such as:
71 // vendor | ... 71 // vendor | ...
72 // version | ... 72 // version | ...
73 // release_date | ... 73 // release_date | ...
74 // We don't make any assumption that the spaces between "version" and "|" is 74 // We don't make any assumption that the spaces between "version" and "|" is
75 // fixed. So we just match kFirmwarePrefix at the start of the line and find 75 // fixed. So we just match kFirmwarePrefix at the start of the line and find
76 // the first character that is not "|" or space 76 // the first character that is not "|" or space
77 77
78 std::vector<std::string> lines; 78 base::StringPiece firmware_prefix(kFirmwarePrefix);
79 base::SplitString(contents, '\n', &lines); 79 for (const std::string& line : base::SplitString(
80 for (size_t i = 0; i < lines.size(); ++i) { 80 contents, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
81 if (base::StartsWith(lines[i], kFirmwarePrefix, 81 if (base::StartsWith(line, firmware_prefix,
82 base::CompareCase::INSENSITIVE_ASCII)) { 82 base::CompareCase::INSENSITIVE_ASCII)) {
83 std::string str = lines[i].substr(std::string(kFirmwarePrefix).size()); 83 std::string str = line.substr(firmware_prefix.size());
84 size_t found = str.find_first_not_of("| "); 84 size_t found = str.find_first_not_of("| ");
85 if (found != std::string::npos) 85 if (found != std::string::npos)
86 return str.substr(found); 86 return str.substr(found);
87 } 87 }
88 } 88 }
89 return std::string(); 89 return std::string();
90 } 90 }
91 91
92 } // namespace version_loader 92 } // namespace version_loader
93 } // namespace chromeos 93 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698