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

dirstate: don't scan for added files if there are none

Minor optimization: we don't need to scan for added files, if
we know from the dirstate that there aren't any.
This safes us from scanning the parsed dirstate looking for e.g.
build dirs and the like. 'Zero add' dirstates are quite frequent.

Changeset 20b0a02116a6

Parent 422e9c472bbb

by Adrian Buehlmann

Changes to 3 files · Browse files at 20b0a02116a6 Showing diff from parent 422e9c472bbb Diff from another changeset...

 
60
61
62
 
 
 
 
63
64
 
65
66
67
 
60
61
62
63
64
65
66
67
 
68
69
70
71
@@ -60,8 +60,12 @@
 {   std::string path = WideToMultibyte(pwszPath);   + char filterStatus = 0; + if (myTortoiseClass == TORTOISE_OLE_ADDED) + filterStatus = 'A'; +   char status = 0; - if (!HgQueryDirstate(path, status)) + if (!HgQueryDirstate(path, filterStatus, status))   return S_FALSE;     if (myTortoiseClass == TORTOISE_OLE_ADDED && status == 'A')
 
98
99
100
 
 
101
102
103
 
113
114
115
 
 
116
117
 
 
118
119
120
 
161
162
163
 
 
 
164
165
166
 
321
322
323
324
 
 
325
326
327
 
355
356
357
 
 
 
358
359
360
 
98
99
100
101
102
103
104
105
 
115
116
117
118
119
120
121
122
123
124
125
126
 
167
168
169
170
171
172
173
174
175
 
330
331
332
 
333
334
335
336
337
 
365
366
367
368
369
370
371
372
373
@@ -98,6 +98,8 @@
  typedef std::deque<direntry> EntriesT;     EntriesT entries; + + unsigned num_added_; // number of entries that have state 'a'    public:   typedef EntriesT::size_type size_type; @@ -113,8 +115,12 @@
  Iter begin() const { return entries.begin(); }   Iter end() const { return entries.end(); }   size_type size() const { return entries.size(); } + + unsigned num_added() const { return num_added_; }    private: + dirstate(): num_added_(0) {} +   static uint32_t ntohl(uint32_t x)   {   return ((x & 0x000000ffUL) << 24) | @@ -161,6 +167,9 @@
    e.name = &temp[0];   + if (e.state == 'a') + ++pd->num_added_; +   pd->add(e);   }   @@ -321,7 +330,8 @@
 }     -int HgQueryDirstate(const std::string& path, char& outStatus) +int HgQueryDirstate( + const std::string& path, const char& filterStatus, char& outStatus)  {   struct _stat stat;   if (0 != lstat(path.c_str(), stat)) @@ -355,6 +365,9 @@
  return 0;   }   + if (filterStatus == 'A' && pd->num_added() == 0) + return 0; +   for (size_t i = 0; i < relpath.size(); ++i)   {   if (relpath[i] == '\\')
 
3
4
5
6
 
 
7
8
 
3
4
5
 
6
7
8
9
@@ -3,6 +3,7 @@
   #include <string>   -int HgQueryDirstate(const std::string& path, char& outStatus); +int HgQueryDirstate( + const std::string& path, const char& filterStatus, char& outStatus);    #endif