]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Avoid an if() in optimized mode by writing the Assert in a more clever way.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 27 Jan 2014 16:42:35 +0000 (16:42 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 27 Jan 2014 16:42:35 +0000 (16:42 +0000)
git-svn-id: https://svn.dealii.org/trunk@32327 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 166a642a235894a9cee92231f3fcf4576c51bf7a..2ed89bee18ec555b87cadcfc6365bb923d41cca1 100644 (file)
@@ -1,7 +1,7 @@
 // ---------------------------------------------------------------------
 // $Id$
 //
-// Copyright (C) 2009 - 2013 by the deal.II authors
+// Copyright (C) 2009 - 2014 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -743,17 +743,12 @@ IndexSet::nth_index_in_set (const unsigned int n) const
       range_end   = ranges.end();
     }
 
-  std::vector<Range>::const_iterator
+  const std::vector<Range>::const_iterator
   p = Utilities::lower_bound(range_begin, range_end, r,
                              Range::nth_index_compare);
 
-  if (p != ranges.end())
-    return p->begin + (n-p->nth_index_in_set);
-  else
-    {
-      Assert (false, ExcInternalError());
-      return numbers::invalid_dof_index;
-    }
+  Assert (p != ranges.end(), ExcInternalError());
+  return p->begin + (n-p->nth_index_in_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.