]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Cache loop bounds.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 2 Aug 2011 08:59:22 +0000 (08:59 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 2 Aug 2011 08:59:22 +0000 (08:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@23987 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/sparse_matrix.templates.h

index e73595b042a90cde6827de1ea52b7f4f09ae5630..1c899618cc159f5d520270a0bfc5257adfc38efc 100644 (file)
@@ -280,7 +280,8 @@ SparseMatrix<number>::n_actually_nonzero_elements (const double threshold) const
   Assert (cols != 0, ExcNotInitialized());
   Assert (threshold >= 0, ExcMessage ("Negative threshold!"));
   unsigned int nnz = 0;
-  for (unsigned int i=0; i<n_nonzero_elements(); ++i)
+  const unsigned int nnz_alloc = n_nonzero_elements();
+  for (unsigned int i=0; i<nnz_alloc; ++i)
     if (std::fabs(val[i]) > threshold)
       ++nnz;
   return nnz;

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.