From 0216e3c95260ce37f7a360505ea56cd8434a78db Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Tue, 9 Apr 2019 13:50:51 -0400 Subject: [PATCH] Use references and clean up a bit --- source/base/subscriptor.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/base/subscriptor.cc b/source/base/subscriptor.cc index 973e5d2e1f..9aa3656845 100644 --- a/source/base/subscriptor.cc +++ b/source/base/subscriptor.cc @@ -136,13 +136,9 @@ Subscriptor::subscribe(std::atomic *const validity, object_info = &typeid(*this); ++counter; - const std::string name = (!id.empty()) ? id : unknown_subscriber; + const std::string &name = id.empty() ? unknown_subscriber : id; - map_iterator it = counter_map.find(name); - if (it == counter_map.end()) - counter_map.insert(map_value_type(name, 1U)); - else - it->second++; + ++counter_map[name]; *validity = true; validity_pointers.push_back(validity); @@ -154,7 +150,8 @@ void Subscriptor::unsubscribe(std::atomic *const validity, const std::string & id) const { - const std::string name = (!id.empty()) ? id : unknown_subscriber; + const std::string &name = id.empty() ? unknown_subscriber : id; + if (counter == 0) { AssertNothrow(counter > 0, ExcNoSubscriber(object_info->name(), name)); -- 2.39.5