From: khizmax Date: Fri, 29 Jul 2016 15:53:09 +0000 (+0300) Subject: improved clear() X-Git-Tag: v2.2.0~169 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=de819d282f4fecd5dd12932108c9c52656a6f226;p=libcds.git improved clear() --- diff --git a/cds/intrusive/mspriority_queue.h b/cds/intrusive/mspriority_queue.h index ba3db521..5d3d0805 100644 --- a/cds/intrusive/mspriority_queue.h +++ b/cds/intrusive/mspriority_queue.h @@ -386,11 +386,9 @@ namespace cds { namespace intrusive { template void clear_with( Func f ) { - while ( !empty() ) { - value_type * pVal = pop(); - if ( pVal ) - f( *pVal ); - } + value_type * pVal; + while (( pVal = pop()) != nullptr ) + f( *pVal ); } /// Checks is the priority queue is empty