vec.data() and vec.data() + vec.size() are both safe even if the vector is empty.
authorRui Ueyama <ruiu@google.com>
Wed, 8 Apr 2015 21:13:23 +0000 (21:13 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 8 Apr 2015 21:13:23 +0000 (21:13 +0000)
llvm-svn: 234436

lld/include/lld/Core/File.h

index cf95f5a..cfb58eb 100644 (file)
@@ -199,14 +199,12 @@ protected:
   class atom_collection_vector : public atom_collection<T> {
   public:
     atom_iterator<T> begin() const override {
-      auto *it = _atoms.empty() ? nullptr
-                                : reinterpret_cast<const void *>(_atoms.data());
+      const void *it = _atoms.data();
       return atom_iterator<T>(*this, it);
     }
 
     atom_iterator<T> end() const override {
-      auto *it = _atoms.empty() ? nullptr : reinterpret_cast<const void *>(
-                                                _atoms.data() + _atoms.size());
+      const void *it = _atoms.data() + _atoms.size();
       return atom_iterator<T>(*this, it);
     }