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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 18:29:19 PST 2022


MaskRay added inline comments.


================
Comment at: llvm/include/llvm/ADT/SmallVector.h:1237-1248
+    this->destroy_range(this->begin(), this->end());
+    if (RHS.empty()) {
+      this->Size = 0;
+    } else {
+      if (!this->isSmall())
+        free(this->begin());
+      this->BeginX = RHS.BeginX;
----------------
lichray wrote:
> where `assignRemote` is your current code. Does that work?
In the generated code, `this->destroy_range(this->begin(), this->end());` will be called twice, while the current version calls this function just once...


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