Skip to content

Commit

Permalink
refactored checkForChange to have one for loop
Browse files Browse the repository at this point in the history
finds highest new rctime inside first for loop instead of queuing new rctimes to find the highest after
  • Loading branch information
joshuaboud authored Sep 25, 2019
1 parent 0b00de4 commit 2e83835
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions crawler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,15 @@ void crawler(fs::path path, std::vector<fs::path> &queue, const fs::path &snapdi

bool checkForChange(const fs::path &path, const timespec &last_rctime, timespec &rctime){
bool change = false;
std::vector<timespec> rctimes;
timespec temp_rctime;
for(fs::directory_iterator itr(path);
itr != fs::directory_iterator(); *itr++){
if((rctime = get_rctime(*itr)) > last_rctime){
if((temp_rctime = get_rctime(*itr)) > last_rctime){
change = true;
rctimes.push_back(rctime);
if(temp_rctime > rctime) rctime = temp_rctime; // get highest
}
}
if(change){
for(timespec i : rctimes)
if(i > rctime) rctime = i;
return true;
}
return false;
return change;
}

int count(fs::path path, FilesOrDirs choice){
Expand Down

0 comments on commit 2e83835

Please sign in to comment.