Skip to content

Commit

Permalink
Merge pull request #438 from wolfp/clean-efficiency
Browse files Browse the repository at this point in the history
Improve the efficiency of -t clean
  • Loading branch information
evmar committed Oct 4, 2012
2 parents 44f2cb6 + 931aac4 commit 302b641
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/clean.cc
Expand Up @@ -29,6 +29,7 @@ Cleaner::Cleaner(State* state, const BuildConfig& config)
: state_(state),
config_(config),
removed_(),
cleaned_(),
cleaned_files_count_(0),
disk_interface_(new RealDiskInterface),
status_(0) {
Expand All @@ -40,6 +41,7 @@ Cleaner::Cleaner(State* state,
: state_(state),
config_(config),
removed_(),
cleaned_(),
cleaned_files_count_(0),
disk_interface_(disk_interface),
status_(0) {
Expand Down Expand Up @@ -134,9 +136,16 @@ void Cleaner::DoCleanTarget(Node* target) {
}
for (vector<Node*>::iterator n = e->inputs_.begin(); n != e->inputs_.end();
++n) {
DoCleanTarget(*n);
Node* next = *n;
// call DoCleanTarget recursively if this node has not been visited
if (cleaned_.count(next) == 0) {
DoCleanTarget(next);
}
}
}

// mark this target to be cleaned already
cleaned_.insert(target);
}

int Cleaner::CleanTarget(Node* target) {
Expand Down Expand Up @@ -249,4 +258,5 @@ void Cleaner::Reset() {
status_ = 0;
cleaned_files_count_ = 0;
removed_.clear();
cleaned_.clear();
}
1 change: 1 addition & 0 deletions src/clean.h
Expand Up @@ -95,6 +95,7 @@ class Cleaner {
State* state_;
const BuildConfig& config_;
set<string> removed_;
set<Node*> cleaned_;
int cleaned_files_count_;
DiskInterface* disk_interface_;
int status_;
Expand Down

0 comments on commit 302b641

Please sign in to comment.