summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/cookies/cookies_api.cc
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 05:45:17 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 05:45:17 +0000
commite59558b78e8c6a1b0bd916a724724b638c3c91b6 (patch)
tree712268a7e9e1cd552f309d89641b2bed5ad06322 /chrome/browser/extensions/api/cookies/cookies_api.cc
parent31fcd34da3797bc49160620ef8c94a38652c0587 (diff)
downloadchromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.zip
chromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.tar.gz
chromium_src-e59558b78e8c6a1b0bd916a724724b638c3c91b6.tar.bz2
Rewrite std::string("") to std::string(), Linux edition.
This patch was generated by running the empty_string clang tool across the Chromium Linux compilation database. Implicitly or explicitly constructing std::string() with a "" argument is inefficient as the caller needs to emit extra instructions to pass an argument, and the constructor needlessly copies a byte into internal storage. Rewriting these instances to simply call the default constructor appears to save ~14-18 kilobytes on an optimized release build. BUG=none Review URL: https://codereview.chromium.org/13145003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/cookies/cookies_api.cc')
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_api.cc55
1 files changed, 31 insertions, 24 deletions
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc
index f3a4a35..c35b830 100644
--- a/chrome/browser/extensions/api/cookies/cookies_api.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -203,8 +203,9 @@ bool CookiesGetFunction::RunImpl() {
if (!ParseUrl(parsed_args_->details.url, &url_, true))
return false;
- std::string store_id = parsed_args_->details.store_id.get() ?
- *parsed_args_->details.store_id : "";
+ std::string store_id =
+ parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
+ : std::string();
net::URLRequestContextGetter* store_context = NULL;
if (!ParseStoreContext(&store_id, &store_context))
return false;
@@ -276,8 +277,9 @@ bool CookiesGetAllFunction::RunImpl() {
return false;
}
- std::string store_id = parsed_args_->details.store_id.get() ?
- *parsed_args_->details.store_id : "";
+ std::string store_id =
+ parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
+ : std::string();
net::URLRequestContextGetter* store_context = NULL;
if (!ParseStoreContext(&store_id, &store_context))
return false;
@@ -339,8 +341,9 @@ bool CookiesSetFunction::RunImpl() {
if (!ParseUrl(parsed_args_->details.url, &url_, true))
return false;
- std::string store_id = parsed_args_->details.store_id.get() ?
- *parsed_args_->details.store_id : "";
+ std::string store_id =
+ parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
+ : std::string();
net::URLRequestContextGetter* store_context = NULL;
if (!ParseStoreContext(&store_id, &store_context))
return false;
@@ -374,17 +377,19 @@ void CookiesSetFunction::SetCookieOnIOThread() {
cookie_monster->SetCookieWithDetailsAsync(
url_,
- parsed_args_->details.name.get() ? *parsed_args_->details.name : "",
- parsed_args_->details.value.get() ? *parsed_args_->details.value : "",
- parsed_args_->details.domain.get() ? *parsed_args_->details.domain : "",
- parsed_args_->details.path.get() ? *parsed_args_->details.path : "",
+ parsed_args_->details.name.get() ? *parsed_args_->details.name
+ : std::string(),
+ parsed_args_->details.value.get() ? *parsed_args_->details.value
+ : std::string(),
+ parsed_args_->details.domain.get() ? *parsed_args_->details.domain
+ : std::string(),
+ parsed_args_->details.path.get() ? *parsed_args_->details.path
+ : std::string(),
expiration_time,
- parsed_args_->details.secure.get() ?
- *parsed_args_->details.secure.get() :
- false,
- parsed_args_->details.http_only.get() ?
- *parsed_args_->details.http_only :
- false,
+ parsed_args_->details.secure.get() ? *parsed_args_->details.secure.get()
+ : false,
+ parsed_args_->details.http_only.get() ? *parsed_args_->details.http_only
+ : false,
base::Bind(&CookiesSetFunction::PullCookie, this));
}
@@ -406,8 +411,9 @@ void CookiesSetFunction::PullCookieCallback(
// Return the first matching cookie. Relies on the fact that the
// CookieMonster returns them in canonical order (longest path, then
// earliest creation time).
- std::string name = parsed_args_->details.name.get() ?
- *parsed_args_->details.name : "";
+ std::string name =
+ parsed_args_->details.name.get() ? *parsed_args_->details.name
+ : std::string();
if (it->Name() == name) {
scoped_ptr<Cookie> cookie(
cookies_helpers::CreateCookie(*it, *parsed_args_->details.store_id));
@@ -425,10 +431,10 @@ void CookiesSetFunction::PullCookieCallback(
void CookiesSetFunction::RespondOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!success_) {
- std::string name = parsed_args_->details.name.get() ?
- *parsed_args_->details.name : "";
- error_ = ErrorUtils::FormatErrorMessage(
- keys::kCookieSetFailedError, name);
+ std::string name =
+ parsed_args_->details.name.get() ? *parsed_args_->details.name
+ : std::string();
+ error_ = ErrorUtils::FormatErrorMessage(keys::kCookieSetFailedError, name);
}
SendResponse(success_);
}
@@ -447,8 +453,9 @@ bool CookiesRemoveFunction::RunImpl() {
if (!ParseUrl(parsed_args_->details.url, &url_, true))
return false;
- std::string store_id = parsed_args_->details.store_id.get() ?
- *parsed_args_->details.store_id : "";
+ std::string store_id =
+ parsed_args_->details.store_id.get() ? *parsed_args_->details.store_id
+ : std::string();
net::URLRequestContextGetter* store_context = NULL;
if (!ParseStoreContext(&store_id, &store_context))
return false;