[lld] r225829 - Use init list and move operator instead of swap().
Rui Ueyama
ruiu at google.com
Tue Jan 13 13:09:05 PST 2015
Author: ruiu
Date: Tue Jan 13 15:09:05 2015
New Revision: 225829
URL: http://llvm.org/viewvc/llvm-project?rev=225829&view=rev
Log:
Use init list and move operator instead of swap().
Modified:
lld/trunk/include/lld/Core/InputGraph.h
lld/trunk/include/lld/Driver/WrapperInputGraph.h
Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=225829&r1=225828&r2=225829&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Tue Jan 13 15:09:05 2015
@@ -147,6 +147,10 @@ public:
: InputElement(InputElement::Kind::File), _path(path), _done(false) {
}
+ FileNode(StringRef path, std::unique_ptr<File> f)
+ : InputElement(InputElement::Kind::File), _path(path), _file(std::move(f)),
+ _done(false) {}
+
virtual ErrorOr<StringRef> getPath(const LinkingContext &) const {
return _path;
}
@@ -171,7 +175,7 @@ public:
virtual void addFiles(InputGraph::FileVectorT files) {
assert(files.size() == 1);
assert(!_file);
- _file.swap(files[0]);
+ _file = std::move(files[0]);
}
/// \brief Return the next File thats part of this node to the
@@ -188,7 +192,7 @@ public:
protected:
StringRef _path; // The path of the Input file
- std::unique_ptr<File> _file; // A vector of lld File objects
+ std::unique_ptr<File> _file; // An lld File object
// The next file that would be processed by the resolver
bool _done;
@@ -199,15 +203,13 @@ class SimpleFileNode : public FileNode {
public:
SimpleFileNode(StringRef path) : FileNode(path) {}
SimpleFileNode(StringRef path, std::unique_ptr<File> f)
- : FileNode(path) {
- _file.swap(f);
- }
+ : FileNode(path, std::move(f)) {}
virtual ~SimpleFileNode() {}
/// \brief add a file to the list of files
virtual void appendInputFile(std::unique_ptr<File> f) {
- _file.swap(f);
+ _file = std::move(f);
}
};
Modified: lld/trunk/include/lld/Driver/WrapperInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WrapperInputGraph.h?rev=225829&r1=225828&r2=225829&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WrapperInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/WrapperInputGraph.h Tue Jan 13 15:09:05 2015
@@ -21,9 +21,7 @@ namespace lld {
class WrapperNode : public FileNode {
public:
- WrapperNode(std::unique_ptr<File> file) : FileNode(file->path()) {
- _file.swap(file);
- }
+ WrapperNode(std::unique_ptr<File> f) : FileNode(f->path(), std::move(f)) {}
};
}
More information about the llvm-commits
mailing list