Skip to content
Snippets Groups Projects
Commit 9f1b00b1 authored by Oliver Sander's avatar Oliver Sander
Browse files

Use std::count to implement the count() method. This doesn't really

seem to change much when compiled with optimization (besides the shorter
code), but leads to a 50% run-time reduction when compiled without
optimization.

[[Imported from SVN: r5996]]
parent 3993ff2a
Branches
Tags
No related merge requests found
......@@ -10,8 +10,8 @@
#include <vector>
#include <bitset>
#include <iostream>
#include <algorithm>
#include <dune/common/deprecated.hh>
#include <dune/common/genericiterator.hh>
#include <dune/common/exceptions.hh>
......@@ -555,10 +555,7 @@ namespace Dune {
//! Returns the number of bits that are set.
size_type count() const
{
size_type n = 0;
for(size_type i=0; i<BlocklessBaseClass::size(); ++i)
n += BlocklessBaseClass::operator[](i);
return n;
return std::count(BlocklessBaseClass::begin(), BlocklessBaseClass::end(), true);
}
//! Returns the number of set bits, while each block is masked with 1<<i
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment