]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Optimize cases by asking for the size of a container first before
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Oct 2009 18:49:04 +0000 (18:49 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Oct 2009 18:49:04 +0000 (18:49 +0000)
creating begin/end iterators and seeing if this denotes an empty loop.

git-svn-id: https://svn.dealii.org/trunk@19834 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/index_set.h

index 1bf8729d9b1fc8bb06d7a3466c8c2957213d9dca..acf130640c828e4f04e579cb1d3f68f864d0502f 100644 (file)
@@ -267,17 +267,19 @@ IndexSet::is_element (const unsigned int index) const
 {
                                   // see if it's in the list of
                                   // individual indices
-  if (individual_indices.find (index) != individual_indices.end())
+  if ((individual_indices.size() > 0) &&
+      (individual_indices.find (index) != individual_indices.end()))
     return true;
 
                                   // if not, we need to walk the list
                                   // of contiguous ranges:
-  for (std::set<ContiguousRange, RangeComparison>::const_iterator
-        i = contiguous_ranges.begin();
-       i != contiguous_ranges.end();
-       ++i)
-    if ((index >= i->first) && (index < i->second))
-      return true;
+  if (contiguous_ranges.size() > 0)
+    for (std::set<ContiguousRange, RangeComparison>::const_iterator
+          i = contiguous_ranges.begin();
+        i != contiguous_ranges.end();
+        ++i)
+      if ((index >= i->first) && (index < i->second))
+       return true;
 
                                   // didn't find this index, so it's
                                   // not in the set

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.