]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use references and clean up a bit 7901/head
authorDaniel Arndt <arndtd@ornl.gov>
Tue, 9 Apr 2019 17:50:51 +0000 (13:50 -0400)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 11 Apr 2019 13:28:10 +0000 (15:28 +0200)
source/base/subscriptor.cc

index 973e5d2e1f37fe5abe8d57b5cd7f309ccd5dc975..9aa36568458ee83119060d64c55a5a97472859e4 100644 (file)
@@ -136,13 +136,9 @@ Subscriptor::subscribe(std::atomic<bool> *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<bool> *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));

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.