Fix class member shadowing in folly::ProducerConsumerQueue
authorUladzislau Paulovich <ulad@fb.com>
Fri, 16 Jun 2017 09:27:40 +0000 (02:27 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 16 Jun 2017 09:38:14 +0000 (02:38 -0700)
Summary: Previous version failed to compile with "-Werror=shadow" flag, this commit fixes the problem.

Reviewed By: WillerZ

Differential Revision: D5255814

fbshipit-source-id: c1252474ed5415b47759022bcbabc78c1639e10a

folly/ProducerConsumerQueue.h

index 9ebe65acb46c66dbef1f9ab33e77e07fd968bdeb..d0bf3ec8c3436976a9fe95927f815d7919cf051b 100644 (file)
@@ -64,12 +64,12 @@ struct ProducerConsumerQueue {
     // (No real synchronization needed at destructor time: only one
     // thread can be doing this.)
     if (!std::is_trivially_destructible<T>::value) {
-      size_t read = readIndex_;
-      size_t end = writeIndex_;
-      while (read != end) {
-        records_[read].~T();
-        if (++read == size_) {
-          read = 0;
+      size_t readIndex = readIndex_;
+      size_t endIndex = writeIndex_;
+      while (readIndex != endIndex) {
+        records_[readIndex].~T();
+        if (++readIndex == size_) {
+          readIndex = 0;
         }
       }
     }