From 5874636d63a41f5f46e4476012efd7e9d66fb198 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 8 Jan 2013 19:05:05 +0000 Subject: [PATCH] Simplify function. The shortcut doesn't reliably work because it assumes that neither of the two iterators is past-the-end. If we were to check this in the shortcut, then this would negate the benefits of the shortcut to begin with. git-svn-id: https://svn.dealii.org/trunk@27975 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/lac/sparse_matrix.h | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/deal.II/include/deal.II/lac/sparse_matrix.h b/deal.II/include/deal.II/lac/sparse_matrix.h index 96b39d28ff..0eaada198c 100644 --- a/deal.II/include/deal.II/lac/sparse_matrix.h +++ b/deal.II/include/deal.II/lac/sparse_matrix.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -2236,21 +2236,17 @@ namespace SparseMatrixIterators Assert (&accessor.get_matrix() == &other.accessor.get_matrix(), ExcInternalError()); - if ((*this)->row() == other->row()) - return ((*this)->index() - other->index()); - else - { - const SparsityPattern &sparsity = accessor.get_matrix().get_sparsity_pattern(); - const unsigned int this_position - = sparsity.get_rowstart_indices()[(*this)->row()] + (*this)->index(); - const unsigned int other_position - = sparsity.get_rowstart_indices()[other->row()] + other->index(); - - return (this_position - other_position); - } + const SparsityPattern &sparsity = accessor.get_matrix().get_sparsity_pattern(); + const unsigned int this_position + = sparsity.get_rowstart_indices()[(*this)->row()] + (*this)->index(); + const unsigned int other_position + = sparsity.get_rowstart_indices()[other->row()] + other->index(); + + return (this_position - other_position); } + template inline Iterator -- 2.39.5