[PATCH] D35145: Use emplace_back to replace size() and resize().
Dehao Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 10 08:47:14 PDT 2017
danielcdh added a comment.
Looks like it's implementation dependent, both gcc and clang uses loop to implement std::list::size:
#cat test.cc
#include <list>
int p(std::list<int> t) {
return t.size();
}
#g++ --std=c++11 test.cc -S -O2 -o - |grep jne -B4
.L4:
movq (%rdx), %rdx
addq $1, %rax
cmpq %rdx, %rdi
jne .L4
https://reviews.llvm.org/tag/clang/ --std=c++11 test.cc -S -O2 -o - |grep jne -B4
.LBB0_1: # =>This Inner Loop Header: Depth=1
movq (%rcx), %rcx
incl %eax
cmpq %rcx, %rdi
jne .LBB0_1
https://reviews.llvm.org/D35145
More information about the llvm-commits
mailing list