summaryrefslogtreecommitdiffstats
path: root/base/process_util_linux.cc
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 01:06:06 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 01:06:06 +0000
commit7880148170459e61c05225a05e82af2f53b74a6a (patch)
tree435fcd436653eefcc6c5ff59331ea0f2d6a7a45d /base/process_util_linux.cc
parentc87d51abc0a1452c596830f185281d2f8ce1d31e (diff)
downloadchromium_src-7880148170459e61c05225a05e82af2f53b74a6a.zip
chromium_src-7880148170459e61c05225a05e82af2f53b74a6a.tar.gz
chromium_src-7880148170459e61c05225a05e82af2f53b74a6a.tar.bz2
Linux: Try to minimize copying of string information when reading /proc data.
BUG=108760 TEST=none Review URL: http://codereview.chromium.org/9071020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_linux.cc')
-rw-r--r--base/process_util_linux.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 2f433d9..28de6dc 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -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;