From 4d9d09721734da31b5e28980f6a1fefee42cb409 Mon Sep 17 00:00:00 2001 From: pbos Date: Thu, 9 Jul 2015 17:21:06 -0700 Subject: [PATCH] Fix follow-up in webrtc/test/field_trial.cc. BUG=webrtc:4820 R=tommi@webrtc.org Review URL: https://codereview.webrtc.org/1215713019 Cr-Commit-Position: refs/heads/master@{#9563} --- webrtc/test/field_trial.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/webrtc/test/field_trial.cc b/webrtc/test/field_trial.cc index 05ca052a57..51bd920dab 100644 --- a/webrtc/test/field_trial.cc +++ b/webrtc/test/field_trial.cc @@ -46,7 +46,7 @@ void InitFieldTrialsFromString(const std::string& trials_string) { static const char kPersistentStringSeparator = '/'; // Catch an error if this is called more than once. - assert(field_trials_initiated_ == false); + assert(!field_trials_initiated_); field_trials_initiated_ = true; if (trials_string.empty()) @@ -77,10 +77,10 @@ void InitFieldTrialsFromString(const std::string& trials_string) { if (next_item == trials_string.length()) return; } - // LOG does not prints when this is called early on main. + // Using fprintf as LOG does not print when this is called early in main. fprintf(stderr, "Invalid field trials string.\n"); - // Using abort so it crashs both in debug and release mode. + // Using abort so it crashes in both debug and release mode. abort(); } @@ -88,11 +88,14 @@ ScopedFieldTrials::ScopedFieldTrials(const std::string& config) : previous_field_trials_(field_trials_) { assert(field_trials_initiated_); field_trials_initiated_ = false; - field_trials_ = std::map(); + field_trials_.clear(); InitFieldTrialsFromString(config); } ScopedFieldTrials::~ScopedFieldTrials() { + // Should still be initialized, since InitFieldTrials is called from ctor. + // That's why we don't restore the flag. + assert(field_trials_initiated_); field_trials_ = previous_field_trials_; }