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

QueryDirstate.cpp: cache last result, use it if not older than 1s

The shell extension calls for each item (file or folder) all
overlay handlers until a handler returns true. The handlers
are called in the order: unchanged, modified, added.

If an item is modifed or added, we now just take the last cached
status (from the previous call to the unchanged handler) and use
that -- provided it's not older than one second.

We also cache status=0 results. This is especially helpful for
non-repo items, as for these all three handlers are called
by the shell.

Changeset 0ba1bd374891

Parent 3353a5509601

by Adrian Buehlmann

Changes to 2 files · Browse files at 0ba1bd374891 Showing diff from parent 3353a5509601 Diff from another changeset...

 
63
64
65
 
 
66
67
68
 
63
64
65
66
67
68
69
70
@@ -63,6 +63,8 @@
  }   }   + TDEBUG_TRACE("HgRepoRoot::get: calling GetHgRepoRoot('" << path << ")"); +   std::string r = GetHgRepoRoot(path);     bool show_hitcount = !cache.hgroot_.empty() && cache.hitcount_ > 0;
 
27
28
29
 
 
 
 
 
 
 
 
 
 
30
31
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
34
35
 
88
89
90
 
 
91
92
 
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
115
116
117
118
119
120
121
@@ -27,9 +27,36 @@
 #include <shlwapi.h>     +class QueryResult +{ +public: + std::string path_; + char status_; + unsigned tickcount_; + QueryResult(): status_(0), tickcount_(0) {} +}; + +  int HgQueryDirstate(   const std::string& path, const char& filterStatus, char& outStatus)  { + static QueryResult last; + + if (path.empty()) + return 0; + + unsigned tc = GetTickCount(); + + if (last.path_ == path && (tc - last.tickcount_ < 1000)) + { + outStatus = last.status_; + return 1; + } + + last.path_ = path; + last.status_ = 0; + last.tickcount_ = tc; +   if (PathIsRoot(path.c_str()))   return 0;   @@ -88,5 +115,7 @@
  outStatus = e->status(stat);   }   + last.status_ = outStatus; + last.tickcount_ = GetTickCount();   return 1;  }