From 1160bb55a917a9e14a9bad45732c8b04d8f6b301 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 29 Nov 2001 15:18:58 +0000 Subject: [PATCH] Revert order of if-clauses: first check whether an element exist, then access it. git-svn-id: https://svn.dealii.org/trunk@5312 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/source/sparsity_pattern.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/deal.II/lac/source/sparsity_pattern.cc b/deal.II/lac/source/sparsity_pattern.cc index 5aeba9b8b3..2259ccc169 100644 --- a/deal.II/lac/source/sparsity_pattern.cc +++ b/deal.II/lac/source/sparsity_pattern.cc @@ -566,14 +566,16 @@ SparsityPattern::operator () (const unsigned int i, return rowstart[i]; // all other entries are sorted, so - // we can use a binary seach algorithm + // we can use a binary search + // algorithm // - // note that the entries are only sorted - // upon compression, so this would fail - // for non-compressed sparsity patterns; - // however, that is why the Assertion is - // at the top of this function, so it - // may not be called for noncompressed + // note that the entries are only + // sorted upon compression, so this + // would fail for non-compressed + // sparsity patterns; however, that + // is why the Assertion is at the + // top of this function, so it may + // not be called for noncompressed // structures. const unsigned int * const sorted_region_start = (rows==cols ? &colnums[rowstart[i]+1] : @@ -581,8 +583,7 @@ SparsityPattern::operator () (const unsigned int i, const unsigned int * const p = optimized_lower_bound (sorted_region_start, &colnums[rowstart[i+1]], j); - if ((*p == j) && - (p != &colnums[rowstart[i+1]])) + if ((p != &colnums[rowstart[i+1]]) && (*p == j)) return (p - &colnums[0]); else return invalid_entry; -- 2.39.5