From: Daniel Arndt Date: Tue, 9 Apr 2019 17:50:51 +0000 (-0400) Subject: Use references and clean up a bit X-Git-Tag: v9.1.0-rc1~208^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7901%2Fhead;p=dealii.git Use references and clean up a bit --- 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));