Skip to content

Commit

Permalink
Use size_type for operator[].
Browse files Browse the repository at this point in the history
This matches std::vector and is more efficient as it avoids
truncations.

With this the text segment of opt goes from 19705442 bytes
to 19703930 bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221973 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Nov 14, 2014
1 parent 5d94c2a commit dada992
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/llvm/ADT/SmallVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ class SmallVectorTemplateCommon : public SmallVectorBase {
/// Return a pointer to the vector's buffer, even if empty().
const_pointer data() const { return const_pointer(begin()); }

reference operator[](unsigned idx) {
reference operator[](size_type idx) {
assert(begin() + idx < end());
return begin()[idx];
}
const_reference operator[](unsigned idx) const {
const_reference operator[](size_type idx) const {
assert(begin() + idx < end());
return begin()[idx];
}
Expand Down

0 comments on commit dada992

Please sign in to comment.