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 ba3db52..5d3d080 100644 (file)
@@ -386,11 +386,9 @@ namespace cds { namespace intrusive {
         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