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

Unified Diff: base/process_util_linux.cc

Issue 9071020: Linux: Try to minimize copying of string information when reading /proc data. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_linux.cc
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 2f433d984eb628dbdeee3d6f711d303939ceb4ee..e4a24e75033765d7985afdbc037c1f9f40637317 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -123,18 +123,18 @@ ProcessId GetParentProcessId(ProcessHandle process) {
StringTokenizer tokenizer(status, ":\n");
ParsingState state = KEY_NAME;
- std::string last_key_name;
+ StringPiece last_key_name;
while (tokenizer.GetNext()) {
switch (state) {
case KEY_NAME:
- last_key_name = tokenizer.token();
+ last_key_name = tokenizer.token_piece();
state = KEY_VALUE;
break;
case KEY_VALUE:
DCHECK(!last_key_name.empty());
if (last_key_name == "PPid") {
int ppid;
- base::StringToInt(tokenizer.token(), &ppid);
+ base::StringToInt(tokenizer.token_piece(), &ppid);
return ppid;
}
state = KEY_NAME;
@@ -380,12 +380,12 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
}
if (last_key_name.starts_with(private_prefix)) {
int cur;
- base::StringToInt(tokenizer.token(), &cur);
+ base::StringToInt(tokenizer.token_piece(), &cur);
private_kb += cur;
} else if (last_key_name.starts_with(pss_prefix)) {
have_pss = true;
int cur;
- base::StringToInt(tokenizer.token(), &cur);
+ base::StringToInt(tokenizer.token_piece(), &cur);
pss_kb += cur;
}
state = KEY_NAME;
@@ -490,26 +490,26 @@ bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const {
StringTokenizer tokenizer(proc_io_contents, ": \n");
ParsingState state = KEY_NAME;
- std::string last_key_name;
+ StringPiece last_key_name;
while (tokenizer.GetNext()) {
switch (state) {
case KEY_NAME:
- last_key_name = tokenizer.token();
+ last_key_name = tokenizer.token_piece();
state = KEY_VALUE;
break;
case KEY_VALUE:
DCHECK(!last_key_name.empty());
if (last_key_name == "syscr") {
- base::StringToInt64(tokenizer.token(),
+ base::StringToInt64(tokenizer.token_piece(),
reinterpret_cast<int64*>(&(*io_counters).ReadOperationCount));
} else if (last_key_name == "syscw") {
- base::StringToInt64(tokenizer.token(),
+ base::StringToInt64(tokenizer.token_piece(),
reinterpret_cast<int64*>(&(*io_counters).WriteOperationCount));
} else if (last_key_name == "rchar") {
- base::StringToInt64(tokenizer.token(),
+ base::StringToInt64(tokenizer.token_piece(),
reinterpret_cast<int64*>(&(*io_counters).ReadTransferCount));
} else if (last_key_name == "wchar") {
- base::StringToInt64(tokenizer.token(),
+ base::StringToInt64(tokenizer.token_piece(),
reinterpret_cast<int64*>(&(*io_counters).WriteTransferCount));
}
state = KEY_NAME;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698