Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

Directory.cpp: eliminate call recursion on status_imp

Changeset 313005ffe01e

Parent 870d9217bdea

by Adrian Buehlmann

Changes to one file · Browse files at 313005ffe01e Showing diff from parent 870d9217bdea Diff from another changeset...

 
164
165
166
167
168
169
170
171
172
173
174
175
 
 
 
176
177
178
179
 
 
 
180
181
182
 
 
183
184
185
186
 
 
187
188
 
 
 
189
190
191
192
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
195
196
 
164
165
166
 
 
 
 
 
 
 
 
 
167
168
169
170
171
 
 
172
173
174
175
 
 
176
177
178
 
 
 
179
180
181
 
182
183
184
185
 
 
 
 
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
@@ -164,33 +164,44 @@
 char Directory::status_imp(const std::string& hgroot)  {   bool added = false; - - for (DirsT::iterator i = subdirs_.begin(); i != subdirs_.end(); ++i) - { - char s = (*i)->status_imp(hgroot); - if (s == 'M') - return 'M'; - if (s == 'A') - added = true; - } + + std::vector<Directory*> todo; + todo.push_back(this);     Winstat stat; - const std::string basepath = hgroot + "/" + path() + "/"; - for (FilesT::iterator i = files_.begin(); i != files_.end(); ++i) + std::string basepath; + + while (!todo.empty())   { - if (i->state == 'r') - return 'M'; // file was removed, report dir as modified + Directory* const d = todo.back(); + todo.pop_back();   - std::string p = basepath + i->name; - if (0 != stat.lstat(p.c_str())) - return 'M'; // file is missing, report dir as modified + //TDEBUG_TRACE("Directory(" << path() << ")::status_imp: " + // "popped '" << d->path() << "'");   - char s = i->status(stat); + if (!d->files_.empty()) + { + basepath = hgroot + "/" + d->path() + "/";   - if (s == 'M') - return 'M'; - if (s == 'A') - added = true; + for (FilesT::iterator i = d->files_.begin(); i != d->files_.end(); ++i) + { + if (i->state == 'r') + return 'M'; // file was removed, report dir as modified + + std::string p = basepath + i->name; + if (0 != stat.lstat(p.c_str())) + return 'M'; // file is missing, report dir as modified + + char s = i->status(stat); + + if (s == 'M') + return 'M'; + if (s == 'A') + added = true; + } + } + + todo.insert(todo.end(), d->subdirs_.begin(), d->subdirs_.end());   }     if (added)