improved clear()
authorkhizmax <khizmax@gmail.com>
Fri, 29 Jul 2016 15:53:09 +0000 (18:53 +0300)
committerkhizmax <khizmax@gmail.com>
Fri, 29 Jul 2016 15:53:09 +0000 (18:53 +0300)
cds/intrusive/mspriority_queue.h

index ba3db521c1215e9c124ce53b75347d39b84375ec..5d3d0805816cf366660e87f72e379ef145900987 100644 (file)
@@ -386,11 +386,9 @@ namespace cds { namespace intrusive {
         template <typename Func>
         void clear_with( Func f )
         {
         template <typename Func>
         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
         }
 
         /// Checks is the priority queue is empty