Skip to content

Commit

Permalink
Let us not construct a new iterator each time "end()" is called.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Mar 7, 2017
1 parent d712200 commit b04a575
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/concise.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ template <bool wah_mode = false> class ConciseSet {

const_iterator begin() const;

const_iterator end() const;
const_iterator & end() const;

bool contains(uint32_t o) const {
if (isEmpty() || ((int32_t)o > last) || (o > MAX_ALLOWED_INTEGER)) {
Expand Down Expand Up @@ -1018,7 +1018,8 @@ ConciseSet<wah_mode>::begin() const {
}

template <bool wah_mode>
inline ConciseSetBitForwardIterator<wah_mode>
inline ConciseSetBitForwardIterator<wah_mode>&
ConciseSet<wah_mode>::end() const {
return ConciseSetBitForwardIterator<wah_mode>(*this, true);
static ConciseSetBitForwardIterator<wah_mode> endp(*this, true);
return endp;
}

0 comments on commit b04a575

Please sign in to comment.