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

DirectoryStatus: cache last used

Changeset 7aaa1ee7ff7c

Parent 7eb6164ccfef

by Adrian Buehlmann

Changes to 3 files · Browse files at 7aaa1ee7ff7c Showing diff from parent 7eb6164ccfef Diff from another changeset...

 
95
96
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@@ -95,3 +95,35 @@
    return 1;  } + + +struct CacheEntry +{ + std::string hgroot_; + DirectoryStatus ds_; + unsigned tickcount_; + + CacheEntry(): tickcount_(0) {}; +}; + + +DirectoryStatus* DirectoryStatus::get(const std::string& hgroot) +{ + static CacheEntry ce; + + unsigned tc = GetTickCount(); + + if (ce.hgroot_ == hgroot && (tc - ce.tickcount_) < 2000) + return &ce.ds_; + + ce.hgroot_.clear(); + + if (ce.ds_.read(hgroot) == 0) + return 0; + + ce.hgroot_ = hgroot; + ce.tickcount_ = GetTickCount(); + return &ce.ds_; +} + +
 
32
33
34
 
 
 
 
35
36
37
 
32
33
34
35
36
37
38
39
 
40
@@ -32,6 +32,9 @@
  V v_;    public: + static DirectoryStatus* get(const std::string& hgroot); + char status(const std::string& relpath) const; + +private:   int read(const std::string& hgroot); - char status(const std::string& relpath) const;  };
 
56
57
58
59
60
 
 
61
62
63
 
56
57
58
 
 
59
60
61
62
63
@@ -56,8 +56,8 @@
    if (PathIsDirectory(path.c_str()))   { - std::auto_ptr<DirectoryStatus> pds(new DirectoryStatus()); - if (!pds->read(hgroot)) + DirectoryStatus* pds = DirectoryStatus::get(hgroot); + if (!pds)   return 0;     outStatus = pds->status(relpath);