Use size_type for operator[].
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 14 Nov 2014 07:02:38 +0000 (07:02 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 14 Nov 2014 07:02:38 +0000 (07:02 +0000)
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

include/llvm/ADT/SmallVector.h

index 59cb80624d6bdaaadfcb689f02d5dd17c3265ef1..21175413f09650dfaacfd524bee5e13f08742cde 100644 (file)
@@ -134,11 +134,11 @@ public:
   /// 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];
   }