From: bangerth Date: Mon, 27 Jan 2014 16:42:35 +0000 (+0000) Subject: Avoid an if() in optimized mode by writing the Assert in a more clever way. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3ccab9f4a5d1ab8e6013388d038141d93a7c5df;p=dealii-svn.git Avoid an if() in optimized mode by writing the Assert in a more clever way. git-svn-id: https://svn.dealii.org/trunk@32327 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/index_set.h b/deal.II/include/deal.II/base/index_set.h index 166a642a23..2ed89bee18 100644 --- a/deal.II/include/deal.II/base/index_set.h +++ b/deal.II/include/deal.II/base/index_set.h @@ -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::const_iterator + const std::vector::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); }