[PATCH] D130361: [NFC] Use more appropriate SmallVectorImpl::append call in std::initializer_list SmallVector constructor

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 07:21:15 PDT 2022


yurai007 created this revision.
yurai007 added reviewers: nikic, dexonsmith, wolfgangp, barannikov88.
Herald added a project: All.
yurai007 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Since we are in constructor there is no need to perform redundant call to SmallVectorImpl::clear() inside assign function.
Although calling cheaper append function instead assign doesn't make any difference on optimized builds (DSE does the job removing stores), we still save some cycles 
for debug binaries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130361

Files:
  llvm/include/llvm/ADT/SmallVector.h


Index: llvm/include/llvm/ADT/SmallVector.h
===================================================================
--- llvm/include/llvm/ADT/SmallVector.h
+++ llvm/include/llvm/ADT/SmallVector.h
@@ -1212,7 +1212,7 @@
   }
 
   SmallVector(std::initializer_list<T> IL) : SmallVectorImpl<T>(N) {
-    this->assign(IL);
+    this->append(IL);
   }
 
   SmallVector(const SmallVector &RHS) : SmallVectorImpl<T>(N) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130361.446823.patch
Type: text/x-patch
Size: 408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220722/f525f38f/attachment.bin>


More information about the llvm-commits mailing list