[llvm] r221973 - Use size_type for operator[].

Rafael Espindola rafael.espindola at gmail.com
Thu Nov 13 23:02:39 PST 2014


Author: rafael
Date: Fri Nov 14 01:02:38 2014
New Revision: 221973

URL: http://llvm.org/viewvc/llvm-project?rev=221973&view=rev
Log:
Use size_type for operator[].

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.

Modified:
    llvm/trunk/include/llvm/ADT/SmallVector.h

Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=221973&r1=221972&r2=221973&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Fri Nov 14 01:02:38 2014
@@ -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];
   }





More information about the llvm-commits mailing list