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
This commit is contained in:
Rui Ueyama 2014-04-03 19:51:14 +00:00
parent 275542a40e
commit 4469ce6c7b
3 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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();
}

View File

@ -111,7 +111,7 @@ std::vector<ImportTableEntryAtom *> ImportDirectoryAtom::createImportTableAtoms(
} // namespace idata
void IdataPass::perform(std::unique_ptr<MutableFile> &file) {
if (file->sharedLibrary().size() == 0)
if (file->sharedLibrary().empty())
return;
idata::Context context(*file, _dummyFile);