diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 08:46:45 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-09 08:46:45 +0000 |
commit | 007b3f812fc9c989fb99d4a668d8bd9c7807ad81 (patch) | |
tree | 43e69dd0f4e4dbbe68afb6319fa18cee07a4be64 /base | |
parent | 2bde7e94eb8f402839145e48924391a5c645a554 (diff) | |
download | chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.zip chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.tar.gz chromium_src-007b3f812fc9c989fb99d4a668d8bd9c7807ad81.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
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=193020
Review URL: https://codereview.chromium.org/13145003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
25 files changed, 91 insertions, 79 deletions
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc index 8376660..782f07b 100644 --- a/base/debug/trace_event_unittest.cc +++ b/base/debug/trace_event_unittest.cc @@ -1535,7 +1535,7 @@ TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) { trace_log->SetEnabled(std::string("foo2"), TraceLog::RECORD_UNTIL_FULL); EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo2")); EXPECT_FALSE(*trace_log->GetCategoryEnabled("baz")); - trace_log->SetEnabled(std::string(""), TraceLog::RECORD_UNTIL_FULL); + trace_log->SetEnabled(std::string(), TraceLog::RECORD_UNTIL_FULL); EXPECT_TRUE(*trace_log->GetCategoryEnabled("foo")); EXPECT_TRUE(*trace_log->GetCategoryEnabled("baz")); trace_log->SetDisabled(); @@ -1558,7 +1558,8 @@ TEST_F(TraceEventTestFixture, TraceCategoriesAfterNestedEnable) { TEST_F(TraceEventTestFixture, TraceOptionsParsing) { ManualTestSetUp(); - EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, TraceLog::TraceOptionsFromString("")); + EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, + TraceLog::TraceOptionsFromString(std::string())); EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL, TraceLog::TraceOptionsFromString("record-until-full")); diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index fa2c1ff..8bf164a 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -541,7 +541,8 @@ bool CreateDirectory(const FilePath& full_path) { base::FilePath MakeUniqueDirectory(const base::FilePath& path) { const int kMaxAttempts = 20; for (int attempts = 0; attempts < kMaxAttempts; attempts++) { - int uniquifier = GetUniquePathNumber(path, FILE_PATH_LITERAL("")); + int uniquifier = + GetUniquePathNumber(path, base::FilePath::StringType()); if (uniquifier < 0) break; base::FilePath test_path = (uniquifier == 0) ? path : diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 1f10a335..77dd7ac 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -1846,15 +1846,14 @@ TEST_F(FileUtilTest, FileEnumeratorTest) { // create the files FilePath dir2file = dir2.Append(FILE_PATH_LITERAL("dir2file.txt")); - CreateTextFile(dir2file, L""); + CreateTextFile(dir2file, std::wstring()); FilePath dir2innerfile = dir2inner.Append(FILE_PATH_LITERAL("innerfile.txt")); - CreateTextFile(dir2innerfile, L""); + CreateTextFile(dir2innerfile, std::wstring()); FilePath file1 = temp_dir_.path().Append(FILE_PATH_LITERAL("file1.txt")); - CreateTextFile(file1, L""); - FilePath file2_rel = - dir2.Append(FilePath::kParentDirectory) - .Append(FILE_PATH_LITERAL("file2.txt")); - CreateTextFile(file2_rel, L""); + CreateTextFile(file1, std::wstring()); + FilePath file2_rel = dir2.Append(FilePath::kParentDirectory) + .Append(FILE_PATH_LITERAL("file2.txt")); + CreateTextFile(file2_rel, std::wstring()); FilePath file2_abs = temp_dir_.path().Append(FILE_PATH_LITERAL("file2.txt")); // Only enumerate files. diff --git a/base/files/file_path.cc b/base/files/file_path.cc index 72604e8..01d9eab 100644 --- a/base/files/file_path.cc +++ b/base/files/file_path.cc @@ -552,7 +552,7 @@ string16 FilePath::LossyDisplayName() const { std::string FilePath::MaybeAsASCII() const { if (IsStringASCII(path_)) return path_; - return ""; + return std::string(); } std::string FilePath::AsUTF8Unsafe() const { diff --git a/base/i18n/char_iterator_unittest.cc b/base/i18n/char_iterator_unittest.cc index 6d1294e..509e27c 100644 --- a/base/i18n/char_iterator_unittest.cc +++ b/base/i18n/char_iterator_unittest.cc @@ -11,7 +11,7 @@ namespace base { namespace i18n { TEST(CharIteratorsTest, TestUTF8) { - std::string empty(""); + std::string empty; UTF8CharIterator empty_iter(&empty); ASSERT_TRUE(empty_iter.end()); ASSERT_EQ(0, empty_iter.array_pos()); diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc index e510500..9df0435 100644 --- a/base/json/json_value_serializer_unittest.cc +++ b/base/json/json_value_serializer_unittest.cc @@ -196,7 +196,7 @@ TEST(JSONValueSerializerTest, Roundtrip) { // initialized with a const string. ASSERT_FALSE(serializer.Serialize(*root_dict)); - std::string test_serialization = ""; + std::string test_serialization; JSONStringValueSerializer mutable_serializer(&test_serialization); ASSERT_TRUE(mutable_serializer.Serialize(*root_dict)); ASSERT_EQ(original_serialization, test_serialization); diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc index 4ab5ff9..1f4f9ae 100644 --- a/base/metrics/field_trial.cc +++ b/base/metrics/field_trial.cc @@ -318,7 +318,7 @@ std::string FieldTrialList::FindFullName(const std::string& name) { FieldTrial* field_trial = Find(name); if (field_trial) return field_trial->group_name(); - return ""; + return std::string(); } // static diff --git a/base/metrics/field_trial_unittest.cc b/base/metrics/field_trial_unittest.cc index 81c4f37..bb2c39f 100644 --- a/base/metrics/field_trial_unittest.cc +++ b/base/metrics/field_trial_unittest.cc @@ -86,7 +86,7 @@ TEST_F(FieldTrialTest, Registration) { EXPECT_EQ(name1, trial1->trial_name()); EXPECT_EQ("", trial1->group_name_internal()); - trial1->AppendGroup("", 7); + trial1->AppendGroup(std::string(), 7); EXPECT_EQ(trial1, FieldTrialList::Find(name1)); EXPECT_FALSE(FieldTrialList::Find(name2)); @@ -221,7 +221,7 @@ TEST_F(FieldTrialTest, OneWinner) { std::string winner_name; for (int i = 1; i <= group_count; ++i) { - int might_win = trial->AppendGroup("", 1); + int might_win = trial->AppendGroup(std::string(), 1); // Because we keep appending groups, we want to see if the last group that // was added has been assigned or not. diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc index f6174f3..13aeeb7 100644 --- a/base/metrics/statistics_recorder.cc +++ b/base/metrics/statistics_recorder.cc @@ -308,7 +308,7 @@ StatisticsRecorder::~StatisticsRecorder() { DCHECK(histograms_ && ranges_ && lock_); if (dump_on_exit_) { string output; - WriteGraph("", &output); + WriteGraph(std::string(), &output); DLOG(INFO) << output; } diff --git a/base/metrics/stats_counters.cc b/base/metrics/stats_counters.cc index f763220..12416d9 100644 --- a/base/metrics/stats_counters.cc +++ b/base/metrics/stats_counters.cc @@ -45,7 +45,7 @@ int* StatsCounter::GetPtr() { if (counter_id_ == -1) { counter_id_ = table->FindCounter(name_); if (table->GetSlot() == 0) { - if (!table->RegisterThread("")) { + if (!table->RegisterThread(std::string())) { // There is no room for this thread. This thread // cannot use counters. counter_id_ = 0; diff --git a/base/metrics/stats_table.cc b/base/metrics/stats_table.cc index dede1e4..9585863 100644 --- a/base/metrics/stats_table.cc +++ b/base/metrics/stats_table.cc @@ -431,8 +431,8 @@ int* StatsTable::FindLocation(const char* name) { // Get the slot for this thread. Try to register // it if none exists. int slot = table->GetSlot(); - if (!slot && !(slot = table->RegisterThread(""))) - return NULL; + if (!slot && !(slot = table->RegisterThread(std::string()))) + return NULL; // Find the counter id for the counter. std::string str_name(name); diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc index 00dcafa..5794b6d 100644 --- a/base/nix/mime_util_xdg.cc +++ b/base/nix/mime_util_xdg.cc @@ -344,9 +344,9 @@ size_t IconTheme::MatchesSize(SubDirInfo* info, size_t size) { std::string IconTheme::ReadLine(FILE* fp) { if (!fp) - return ""; + return std::string(); - std::string result = ""; + std::string result; const size_t kBufferSize = 100; char buffer[kBufferSize]; while ((fgets(buffer, kBufferSize - 1, fp)) != NULL) { diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc index d418fdf..d252dae 100644 --- a/base/pickle_unittest.cc +++ b/base/pickle_unittest.cc @@ -134,7 +134,7 @@ TEST(PickleTest, UnalignedSize) { TEST(PickleTest, ZeroLenStr) { Pickle pickle; - EXPECT_TRUE(pickle.WriteString("")); + EXPECT_TRUE(pickle.WriteString(std::string())); PickleIterator iter(pickle); std::string outstr; @@ -144,7 +144,7 @@ TEST(PickleTest, ZeroLenStr) { TEST(PickleTest, ZeroLenWStr) { Pickle pickle; - EXPECT_TRUE(pickle.WriteWString(L"")); + EXPECT_TRUE(pickle.WriteWString(std::wstring())); PickleIterator iter(pickle); std::string outstr; diff --git a/base/prefs/pref_change_registrar_unittest.cc b/base/prefs/pref_change_registrar_unittest.cc index 49da721..f353a8f 100644 --- a/base/prefs/pref_change_registrar_unittest.cc +++ b/base/prefs/pref_change_registrar_unittest.cc @@ -132,7 +132,7 @@ class ObserveSetOfPreferencesTest : public testing::Test { PrefRegistrySimple* registry = pref_service_->registry(); registry->RegisterStringPref(kHomePage, "http://google.com"); registry->RegisterBooleanPref(kHomePageIsNewTabPage, false); - registry->RegisterStringPref(kApplicationLocale, ""); + registry->RegisterStringPref(kApplicationLocale, std::string()); } PrefChangeRegistrar* CreatePrefChangeRegistrar() { diff --git a/base/prefs/pref_service_unittest.cc b/base/prefs/pref_service_unittest.cc index 26fe19a..927f2f7 100644 --- a/base/prefs/pref_service_unittest.cc +++ b/base/prefs/pref_service_unittest.cc @@ -45,7 +45,7 @@ TEST(PrefServiceTest, NoObserverFire) { Mock::VerifyAndClearExpectations(&obs); // Clearing the pref should cause the pref to fire. - const StringValue expected_default_value(""); + const StringValue expected_default_value((std::string())); obs.Expect(pref_name, &expected_default_value); prefs.ClearPref(pref_name); Mock::VerifyAndClearExpectations(&obs); diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index 2af9227..e06d99c 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -161,7 +161,7 @@ std::string GetProcStatsFieldAsString( ProcStatsFields field_num) { if (field_num < VM_COMM || field_num > VM_STATE) { NOTREACHED(); - return ""; + return std::string(); } if (proc_stats.size() > static_cast<size_t>(field_num)) diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index 265a2df..3ce9942 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -758,8 +758,8 @@ TEST_F(ProcessUtilTest, LaunchProcess) { EXPECT_EQ(0, setenv("BASE_TEST", "testing", 1 /* override */)); EXPECT_EQ("testing\n", TestLaunchProcess(env_changes, no_clone_flags)); - env_changes.push_back(std::make_pair(std::string("BASE_TEST"), - std::string(""))); + env_changes.push_back( + std::make_pair(std::string("BASE_TEST"), std::string())); EXPECT_EQ("\n", TestLaunchProcess(env_changes, no_clone_flags)); env_changes[0].second = "foo"; @@ -800,7 +800,7 @@ TEST_F(ProcessUtilTest, AlterEnvironment) { delete[] e; changes.clear(); - changes.push_back(std::make_pair(std::string("A"), std::string(""))); + changes.push_back(std::make_pair(std::string("A"), std::string())); e = base::AlterEnvironment(changes, empty); EXPECT_TRUE(e[0] == NULL); delete[] e; @@ -819,7 +819,7 @@ TEST_F(ProcessUtilTest, AlterEnvironment) { delete[] e; changes.clear(); - changes.push_back(std::make_pair(std::string("A"), std::string(""))); + changes.push_back(std::make_pair(std::string("A"), std::string())); e = base::AlterEnvironment(changes, a2); EXPECT_TRUE(e[0] == NULL); delete[] e; diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index d36b955..d580fba 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -70,7 +70,7 @@ TEST(StringUtilTest, TruncateUTF8ToByteSize) { std::string output; // Empty strings and invalid byte_size arguments - EXPECT_FALSE(Truncated("", 0, &output)); + EXPECT_FALSE(Truncated(std::string(), 0, &output)); EXPECT_EQ(output, ""); EXPECT_TRUE(Truncated("\xe1\x80\xbf", 0, &output)); EXPECT_EQ(output, ""); @@ -319,7 +319,7 @@ TEST(StringUtilTest, CollapseWhitespaceASCII) { } TEST(StringUtilTest, ContainsOnlyWhitespaceASCII) { - EXPECT_TRUE(ContainsOnlyWhitespaceASCII("")); + EXPECT_TRUE(ContainsOnlyWhitespaceASCII(std::string())); EXPECT_TRUE(ContainsOnlyWhitespaceASCII(" ")); EXPECT_TRUE(ContainsOnlyWhitespaceASCII("\t")); EXPECT_TRUE(ContainsOnlyWhitespaceASCII("\t \r \n ")); @@ -712,7 +712,7 @@ void TokenizeTest() { EXPECT_EQ(r[2], STR(" three")); r.clear(); - size = Tokenize(STR(""), STR(","), &r); + size = Tokenize(STR(), STR(","), &r); EXPECT_EQ(0U, size); ASSERT_EQ(0U, r.size()); r.clear(); @@ -761,7 +761,7 @@ TEST(StringUtilTest, JoinString) { in.push_back("c"); EXPECT_EQ("a,b,c", JoinString(in, ',')); - in.push_back(""); + in.push_back(std::string()); EXPECT_EQ("a,b,c,", JoinString(in, ',')); in.push_back(" "); EXPECT_EQ("a|b|c|| ", JoinString(in, '|')); @@ -780,7 +780,7 @@ TEST(StringUtilTest, JoinStringWithString) { parts.push_back("c"); EXPECT_EQ("a, b, c", JoinString(parts, separator)); - parts.push_back(""); + parts.push_back(std::string()); EXPECT_EQ("a, b, c, ", JoinString(parts, separator)); parts.push_back(" "); EXPECT_EQ("a|b|c|| ", JoinString(parts, "|")); @@ -812,10 +812,10 @@ TEST(StringUtilTest, StartsWith) { EXPECT_TRUE(StartsWithASCII("JavaScript:url", "javascript", false)); EXPECT_FALSE(StartsWithASCII("java", "javascript", true)); EXPECT_FALSE(StartsWithASCII("java", "javascript", false)); - EXPECT_FALSE(StartsWithASCII("", "javascript", false)); - EXPECT_FALSE(StartsWithASCII("", "javascript", true)); - EXPECT_TRUE(StartsWithASCII("java", "", false)); - EXPECT_TRUE(StartsWithASCII("java", "", true)); + EXPECT_FALSE(StartsWithASCII(std::string(), "javascript", false)); + EXPECT_FALSE(StartsWithASCII(std::string(), "javascript", true)); + EXPECT_TRUE(StartsWithASCII("java", std::string(), false)); + EXPECT_TRUE(StartsWithASCII("java", std::string(), true)); EXPECT_TRUE(StartsWith(L"javascript:url", L"javascript", true)); EXPECT_FALSE(StartsWith(L"JavaScript:url", L"javascript", true)); @@ -823,10 +823,10 @@ TEST(StringUtilTest, StartsWith) { EXPECT_TRUE(StartsWith(L"JavaScript:url", L"javascript", false)); EXPECT_FALSE(StartsWith(L"java", L"javascript", true)); EXPECT_FALSE(StartsWith(L"java", L"javascript", false)); - EXPECT_FALSE(StartsWith(L"", L"javascript", false)); - EXPECT_FALSE(StartsWith(L"", L"javascript", true)); - EXPECT_TRUE(StartsWith(L"java", L"", false)); - EXPECT_TRUE(StartsWith(L"java", L"", true)); + EXPECT_FALSE(StartsWith(std::wstring(), L"javascript", false)); + EXPECT_FALSE(StartsWith(std::wstring(), L"javascript", true)); + EXPECT_TRUE(StartsWith(L"java", std::wstring(), false)); + EXPECT_TRUE(StartsWith(L"java", std::wstring(), true)); } TEST(StringUtilTest, EndsWith) { @@ -838,14 +838,14 @@ TEST(StringUtilTest, EndsWith) { EXPECT_FALSE(EndsWith(L".plug", L".plugin", false)); EXPECT_FALSE(EndsWith(L"Foo.plugin Bar", L".plugin", true)); EXPECT_FALSE(EndsWith(L"Foo.plugin Bar", L".plugin", false)); - EXPECT_FALSE(EndsWith(L"", L".plugin", false)); - EXPECT_FALSE(EndsWith(L"", L".plugin", true)); - EXPECT_TRUE(EndsWith(L"Foo.plugin", L"", false)); - EXPECT_TRUE(EndsWith(L"Foo.plugin", L"", true)); + EXPECT_FALSE(EndsWith(std::wstring(), L".plugin", false)); + EXPECT_FALSE(EndsWith(std::wstring(), L".plugin", true)); + EXPECT_TRUE(EndsWith(L"Foo.plugin", std::wstring(), false)); + EXPECT_TRUE(EndsWith(L"Foo.plugin", std::wstring(), true)); EXPECT_TRUE(EndsWith(L".plugin", L".plugin", false)); EXPECT_TRUE(EndsWith(L".plugin", L".plugin", true)); - EXPECT_TRUE(EndsWith(L"", L"", false)); - EXPECT_TRUE(EndsWith(L"", L"", true)); + EXPECT_TRUE(EndsWith(std::wstring(), std::wstring(), false)); + EXPECT_TRUE(EndsWith(std::wstring(), std::wstring(), true)); } TEST(StringUtilTest, GetStringFWithOffsets) { @@ -1142,10 +1142,10 @@ TEST(StringUtilTest, ReplaceChars) { TEST(StringUtilTest, ContainsOnlyChars) { // Providing an empty list of characters should return false but for the empty // string. - EXPECT_TRUE(ContainsOnlyChars("", "")); - EXPECT_FALSE(ContainsOnlyChars("Hello", "")); + EXPECT_TRUE(ContainsOnlyChars(std::string(), std::string())); + EXPECT_FALSE(ContainsOnlyChars("Hello", std::string())); - EXPECT_TRUE(ContainsOnlyChars("", "1234")); + EXPECT_TRUE(ContainsOnlyChars(std::string(), "1234")); EXPECT_TRUE(ContainsOnlyChars("1", "1234")); EXPECT_TRUE(ContainsOnlyChars("1", "4321")); EXPECT_TRUE(ContainsOnlyChars("123", "4321")); diff --git a/base/strings/string_split.cc b/base/strings/string_split.cc index f5f19e9..819fdba 100644 --- a/base/strings/string_split.cc +++ b/base/strings/string_split.cc @@ -107,7 +107,8 @@ bool SplitStringIntoKeyValuePairs( success = false; } DCHECK_LE(value.size(), 1U); - kv_pairs->push_back(make_pair(key, value.empty()? "" : value[0])); + kv_pairs->push_back( + make_pair(key, value.empty() ? std::string() : value[0])); } return success; } diff --git a/base/strings/string_split_unittest.cc b/base/strings/string_split_unittest.cc index a950cac..6729497 100644 --- a/base/strings/string_split_unittest.cc +++ b/base/strings/string_split_unittest.cc @@ -36,9 +36,10 @@ class SplitStringIntoKeyValuesTest : public testing::Test { }; TEST_F(SplitStringIntoKeyValuesTest, EmptyInputMultipleValues) { - EXPECT_FALSE(SplitStringIntoKeyValues("", // Empty input - '\t', // Key separators - &key, &values)); + EXPECT_FALSE(SplitStringIntoKeyValues(std::string(), // Empty input + '\t', // Key separators + &key, + &values)); EXPECT_TRUE(key.empty()); EXPECT_TRUE(values.empty()); } @@ -69,9 +70,10 @@ TEST_F(SplitStringIntoKeyValuesTest, KeyWithMultipleValues) { } TEST_F(SplitStringIntoKeyValuesTest, EmptyInputSingleValue) { - EXPECT_FALSE(SplitStringIntoKeyValues("", // Empty input - '\t', // Key separators - &key, &values)); + EXPECT_FALSE(SplitStringIntoKeyValues(std::string(), // Empty input + '\t', // Key separators + &key, + &values)); EXPECT_TRUE(key.empty()); EXPECT_TRUE(values.empty()); } @@ -108,9 +110,9 @@ class SplitStringIntoKeyValuePairsTest : public testing::Test { }; TEST_F(SplitStringIntoKeyValuePairsTest, EmptyString) { - EXPECT_TRUE(SplitStringIntoKeyValuePairs("", - ':', // Key-value delimiters - ',', // Key-value pair delims + EXPECT_TRUE(SplitStringIntoKeyValuePairs(std::string(), + ':', // Key-value delimiters + ',', // Key-value pair delims &kv_pairs)); EXPECT_TRUE(kv_pairs.empty()); } @@ -153,7 +155,7 @@ TEST_F(SplitStringIntoKeyValuePairsTest, DelimiterInValue) { TEST(SplitStringUsingSubstrTest, EmptyString) { std::vector<std::string> results; - SplitStringUsingSubstr("", "DELIMITER", &results); + SplitStringUsingSubstr(std::string(), "DELIMITER", &results); ASSERT_EQ(1u, results.size()); EXPECT_THAT(results, ElementsAre("")); } @@ -162,7 +164,7 @@ TEST(SplitStringUsingSubstrTest, EmptyString) { TEST(StringUtilTest, SplitString) { std::vector<std::wstring> r; - SplitString(L"", L',', &r); + SplitString(std::wstring(), L',', &r); EXPECT_EQ(0U, r.size()); r.clear(); diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index 854f123..57b7af6 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -55,7 +55,7 @@ std::string SysInfo::OperatingSystemName() { struct utsname info; if (uname(&info) < 0) { NOTREACHED(); - return ""; + return std::string(); } return std::string(info.sysname); } @@ -67,7 +67,7 @@ std::string SysInfo::OperatingSystemVersion() { struct utsname info; if (uname(&info) < 0) { NOTREACHED(); - return ""; + return std::string(); } return std::string(info.release); } @@ -78,7 +78,7 @@ std::string SysInfo::OperatingSystemArchitecture() { struct utsname info; if (uname(&info) < 0) { NOTREACHED(); - return ""; + return std::string(); } std::string arch(info.machine); if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { diff --git a/base/test/trace_event_analyzer.cc b/base/test/trace_event_analyzer.cc index 431945b..8457ce9 100644 --- a/base/test/trace_event_analyzer.cc +++ b/base/test/trace_event_analyzer.cc @@ -140,7 +140,7 @@ std::string TraceEvent::GetKnownArgAsString(const std::string& name) const { if (GetArgAsString(name, &arg_string)) return arg_string; NOTREACHED(); - return ""; + return std::string(); } double TraceEvent::GetKnownArgAsDouble(const std::string& name) const { diff --git a/base/test/trace_event_analyzer_unittest.cc b/base/test/trace_event_analyzer_unittest.cc index 33cacbf..52926fd 100644 --- a/base/test/trace_event_analyzer_unittest.cc +++ b/base/test/trace_event_analyzer_unittest.cc @@ -786,7 +786,7 @@ TEST_F(TraceEventAnalyzerTest, FindClosest) { events[0].name = "one"; events[2].name = "two"; events[4].name = "three"; - Query query_named = Query::EventName() != Query::String(""); + Query query_named = Query::EventName() != Query::String(std::string()); Query query_one = Query::EventName() == Query::String("one"); // Only one event matches query_one, so two closest can't be found. @@ -822,7 +822,7 @@ TEST_F(TraceEventAnalyzerTest, CountMatches) { events[0].name = "one"; events[2].name = "two"; events[4].name = "three"; - Query query_named = Query::EventName() != Query::String(""); + Query query_named = Query::EventName() != Query::String(std::string()); Query query_one = Query::EventName() == Query::String("one"); EXPECT_EQ(0u, CountMatches(event_ptrs, Query::Bool(false))); diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 98bc73c..bad83fa 100644 --- a/base/values_unittest.cc +++ b/base/values_unittest.cc @@ -599,7 +599,7 @@ TEST(ValuesTest, RemoveEmptyChildren) { // Make sure we don't prune too much. root->SetBoolean("bool", true); root->Set("empty_dict", new DictionaryValue); - root->SetString("empty_string", ""); + root->SetString("empty_string", std::string()); root.reset(root->DeepCopyWithoutEmptyChildren()); EXPECT_EQ(2U, root->size()); diff --git a/base/vlog_unittest.cc b/base/vlog_unittest.cc index ef7247f..3a508f4 100644 --- a/base/vlog_unittest.cc +++ b/base/vlog_unittest.cc @@ -16,12 +16,20 @@ namespace { TEST(VlogTest, NoVmodule) { int min_log_level = 0; - EXPECT_EQ(0, VlogInfo("", "", &min_log_level).GetVlogLevel("test1")); - EXPECT_EQ(0, VlogInfo("0", "", &min_log_level).GetVlogLevel("test2")); - EXPECT_EQ(0, VlogInfo("blah", "", &min_log_level).GetVlogLevel("test3")); - EXPECT_EQ(0, VlogInfo("0blah1", "", &min_log_level).GetVlogLevel("test4")); - EXPECT_EQ(1, VlogInfo("1", "", &min_log_level).GetVlogLevel("test5")); - EXPECT_EQ(5, VlogInfo("5", "", &min_log_level).GetVlogLevel("test6")); + EXPECT_EQ(0, + VlogInfo(std::string(), std::string(), &min_log_level) + .GetVlogLevel("test1")); + EXPECT_EQ(0, + VlogInfo("0", std::string(), &min_log_level).GetVlogLevel("test2")); + EXPECT_EQ( + 0, VlogInfo("blah", std::string(), &min_log_level).GetVlogLevel("test3")); + EXPECT_EQ( + 0, + VlogInfo("0blah1", std::string(), &min_log_level).GetVlogLevel("test4")); + EXPECT_EQ(1, + VlogInfo("1", std::string(), &min_log_level).GetVlogLevel("test5")); + EXPECT_EQ(5, + VlogInfo("5", std::string(), &min_log_level).GetVlogLevel("test6")); } TEST(VlogTest, MatchVlogPattern) { @@ -92,7 +100,7 @@ TEST(VlogTest, VmoduleDirs) { const char kVModuleSwitch[] = "foo/bar.cc=1,baz\\*\\qux.cc=2,*quux/*=3,*/*-inl.h=4"; int min_log_level = 0; - VlogInfo vlog_info("", kVModuleSwitch, &min_log_level); + VlogInfo vlog_info(std::string(), kVModuleSwitch, &min_log_level); EXPECT_EQ(0, vlog_info.GetVlogLevel("/foo/bar.cc")); EXPECT_EQ(0, vlog_info.GetVlogLevel("bar.cc")); EXPECT_EQ(1, vlog_info.GetVlogLevel("foo/bar.cc")); |