From de819d282f4fecd5dd12932108c9c52656a6f226 Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 29 Jul 2016 18:53:09 +0300 Subject: [PATCH] improved clear() --- cds/intrusive/mspriority_queue.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 -- 2.34.1