From 4469ce6c7b4d5c375e0f3aa54856e5233cd7a28d Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 3 Apr 2014 19:51:14 +0000 Subject: [PATCH] Add empty() to atom_collection. "x.empty()" is more idiomatic than "x.size() == 0". This patch is to add such method and use it in LLD. Differential Revision: http://llvm-reviews.chandlerc.com/D3279 llvm-svn: 205558 --- lld/include/lld/Core/File.h | 1 + lld/lib/Core/Resolver.cpp | 6 +++--- lld/lib/ReaderWriter/PECOFF/IdataPass.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h index e32e58e48905..84ec80a6912d 100644 --- a/lld/include/lld/Core/File.h +++ b/lld/include/lld/Core/File.h @@ -105,6 +105,7 @@ public: virtual const T *deref(const void *it) const = 0; virtual void next(const void *&it) const = 0; virtual uint64_t size() const = 0; + bool empty() const { return size() == 0; } }; /// \brief The class is the iterator type used to iterate through a File's diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 56cee9c17164..f51d68874923 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -78,7 +78,7 @@ void Resolver::handleFile(const File &file) { if (!sharedLibraryFile || _context.addUndefinedAtomsFromSharedLibrary(sharedLibraryFile)) { - progress = (file.undefined().size() > 0); + progress = !file.undefined().empty(); for (const UndefinedAtom *undefAtom : file.undefined()) { doUndefinedAtom(*undefAtom); @@ -101,8 +101,8 @@ void Resolver::handleFile(const File &file) { // If we make some progress on linking, notify that fact to the input file // manager, because it may want to know that for --start-group/end-group. - progress = progress || file.sharedLibrary().size() || - file.absolute().size() || file.defined().size(); + progress = progress || !file.sharedLibrary().empty() || + !file.absolute().empty() || !file.defined().empty(); if (progress) { _context.inputGraph().notifyProgress(); } diff --git a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp index f48a417763f7..578e519373a4 100644 --- a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp +++ b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp @@ -111,7 +111,7 @@ std::vector ImportDirectoryAtom::createImportTableAtoms( } // namespace idata void IdataPass::perform(std::unique_ptr &file) { - if (file->sharedLibrary().size() == 0) + if (file->sharedLibrary().empty()) return; idata::Context context(*file, _dummyFile);