From e3ccab9f4a5d1ab8e6013388d038141d93a7c5df Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 27 Jan 2014 16:42:35 +0000 Subject: [PATCH] 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 --- deal.II/include/deal.II/base/index_set.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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); } -- 2.39.5