diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 01:22:15 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 01:22:15 +0000 |
commit | 810a52ef77564f1674a600317175743176bcc965 (patch) | |
tree | e18a35b4ef980bdb8eaad3c5812228a6e1b3ba16 /base | |
parent | 673ccc1d607a6d7d280d89fedd3fb3bc906a7e27 (diff) | |
download | chromium_src-810a52ef77564f1674a600317175743176bcc965.zip chromium_src-810a52ef77564f1674a600317175743176bcc965.tar.gz chromium_src-810a52ef77564f1674a600317175743176bcc965.tar.bz2 |
Remove most uses of EmptyString(), EmptyWString(), EmptyString16(), and EmptyGURL(), since the code in question can just use the default constructor.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/517054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/string_util.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/base/string_util.h b/base/string_util.h index f0fa6da..ee70a16 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -121,10 +121,15 @@ bool IsWprintfFormatPortable(const wchar_t* format); #error Define string operations appropriately for your platform #endif -// Returns a reference to a globally unique empty string that functions can -// return. Use this to avoid static construction of strings, not to replace -// any and all uses of "std::string()" as nicer-looking sugar. -// These functions are threadsafe. +// These threadsafe functions return references to globally unique empty +// strings. +// +// DO NOT USE THESE AS A GENERAL-PURPOSE SUBSTITUTE FOR DEFAULT CONSTRUCTORS. +// There is only one case where you should use these: functions which need to +// return a string by reference (e.g. as a class member accessor), and don't +// have an empty string to use (e.g. in an error case). These should not be +// used as initializers, function arguments, or return values for functions +// which return by value or outparam. const std::string& EmptyString(); const std::wstring& EmptyWString(); const string16& EmptyString16(); |