Chromium Code Reviews| Index: chrome/browser/chromeos/system/syslogs_provider.cc |
| =================================================================== |
| --- chrome/browser/chromeos/system/syslogs_provider.cc (revision 247534) |
| +++ chrome/browser/chromeos/system/syslogs_provider.cc (working copy) |
| @@ -51,17 +51,17 @@ |
| // Reads a key from the input string erasing the read values + delimiters read |
| // from the initial string |
| std::string ReadKey(std::string* data) { |
| + std::string key; |
| size_t equal_sign = data->find("="); |
| - if (equal_sign == std::string::npos) |
| - return std::string(""); |
| - std::string key = data->substr(0, equal_sign); |
| - data->erase(0, equal_sign); |
| - if (data->size() > 0) { |
| - // erase the equal to sign also |
| - data->erase(0,1); |
| - return key; |
| + if (equal_sign != std::string::npos) { |
| + key = data->substr(0, equal_sign); |
| + data->erase(0, equal_sign); |
| + if (data->size() > 0) { |
| + // erase the equal to sign also |
| + data->erase(0, 1); |
| + } |
| } |
| - return std::string(); |
| + return key; |
|
Nico
2014/01/29 22:15:24
Hate this change. Early returns FTW!
Lei Zhang
2014/01/29 22:20:16
Ok, flipped it back a bit.
|
| } |
| // Reads a value from the input string; erasing the read values from |
| @@ -93,7 +93,8 @@ |
| std::string value = data->substr(0, next_multi); |
| data->erase(0, next_multi + 3); |
| return value; |
| - } else { // single line value |
| + } else { |
| + // single line value |
| size_t endl_pos = data->find_first_of(kNewLineChars); |
| // if we don't find a new line, we just return the rest of the data |
| std::string value = data->substr(0, endl_pos); |