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

Zhihao Yuan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 17:45:48 PST 2022


lichray added inline comments.


================
Comment at: llvm/include/llvm/ADT/SmallVector.h:1033-1039
     this->destroy_range(this->begin(), this->end());
     if (!this->isSmall()) free(this->begin());
     this->BeginX = RHS.BeginX;
     this->Size = RHS.Size;
     this->Capacity = RHS.Capacity;
     RHS.resetToSmall();
     return *this;
----------------



================
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;
----------------
where `assignRemote` is your current code. Does that work?


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