From 5d6ff3d2eed7baf0e5fef4bea53102d09a3f49ba Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 8 Apr 2015 21:13:23 +0000 Subject: [PATCH] vec.data() and vec.data() + vec.size() are both safe even if the vector is empty. llvm-svn: 234436 --- lld/include/lld/Core/File.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h index cf95f5a..cfb58eb 100644 --- a/lld/include/lld/Core/File.h +++ b/lld/include/lld/Core/File.h @@ -199,14 +199,12 @@ protected: class atom_collection_vector : public atom_collection { public: atom_iterator begin() const override { - auto *it = _atoms.empty() ? nullptr - : reinterpret_cast(_atoms.data()); + const void *it = _atoms.data(); return atom_iterator(*this, it); } atom_iterator end() const override { - auto *it = _atoms.empty() ? nullptr : reinterpret_cast( - _atoms.data() + _atoms.size()); + const void *it = _atoms.data() + _atoms.size(); return atom_iterator(*this, it); } -- 2.7.4