[PATCH] D117976: [SmallVector] Optimize move assignment operator for N==0 case

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 24 18:44:46 PST 2022


dexonsmith added inline comments.


================
Comment at: llvm/include/llvm/ADT/SmallVector.h:1245-1246
+      }
+    } else {
+      SmallVectorImpl<T>::operator=(::std::move(RHS));
+    }
----------------
Seems like inverting the condition with an early return would make this easier to read:
```
lang=c++
  if (N) {
    SmallVectorImpl<T>::operator=(std::move(RHS));
    return *this;
  }
  // rest of function without nesting.
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117976/new/

https://reviews.llvm.org/D117976



More information about the llvm-commits mailing list