From 06c17191e161c69b52e7f798112677a309828db8 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 14 Nov 2014 07:02:38 +0000 Subject: [PATCH] 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. llvm-svn: 221973 --- include/llvm/ADT/SmallVector.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 59cb80624d6..21175413f09 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -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]; }