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

shellext: introduce Dirstatecache::cache()

Changeset 2730b8d336aa

Parent b42454569f06

by Adrian Buehlmann

Changes to 2 files · Browse files at 2730b8d336aa Showing diff from parent b42454569f06 Diff from another changeset...

 
21
22
23
24
 
 
 
 
 
 
25
26
27
28
29
30
31
32
33
34
 
 
35
36
37
 
43
44
45
46
 
47
48
49
 
53
54
55
56
 
57
58
59
60
61
62
 
 
 
 
63
64
65
66
67
68
 
 
69
70
71
 
77
78
79
80
 
81
82
83
 
110
111
112
113
 
114
115
116
 
21
22
23
 
24
25
26
27
28
29
30
31
32
33
34
35
 
 
 
 
36
37
38
39
40
 
46
47
48
 
49
50
51
52
 
56
57
58
 
59
60
61
 
 
 
 
62
63
64
65
66
67
68
69
 
 
70
71
72
73
74
 
80
81
82
 
83
84
85
86
 
113
114
115
 
116
117
118
119
@@ -21,17 +21,20 @@
 #include "dirstate.h"  #include "Winstat.h"   -#include <list> + +std::list<Dirstatecache::E>& Dirstatecache::cache() +{ + static std::list<Dirstatecache::E> c; + return c; +}      Dirstate* Dirstatecache::get(const std::string& hgroot)  {   typedef std::list<E>::iterator Iter;   - static std::list<Dirstatecache::E> _cache; - - Iter iter = _cache.begin(); - for (;iter != _cache.end(); ++iter) + Iter iter = cache().begin(); + for (;iter != cache().end(); ++iter)   {   if (hgroot == iter->hgroot)   break; @@ -43,7 +46,7 @@
  unsigned tc = GetTickCount();   bool new_stat = false;   - if (iter == _cache.end()) + if (iter == cache().end())   {   if (stat.lstat(path.c_str()) != 0)   { @@ -53,19 +56,19 @@
  TDEBUG_TRACE("Dirstatecache::get: lstat(" << path <<") ok ");   new_stat = true;   - if (_cache.size() >= 10) + if (cache().size() >= 10)   {   TDEBUG_TRACE("Dirstatecache::get: dropping " - << _cache.back().hgroot); - delete _cache.back().dstate; - _cache.back().dstate = 0; - _cache.pop_back(); + << cache().back().hgroot); + delete cache().back().dstate; + cache().back().dstate = 0; + cache().pop_back();   }     E e;   e.hgroot = hgroot; - _cache.push_front(e); - iter = _cache.begin(); + cache().push_front(e); + iter = cache().begin();   iter->tickcount = tc;   }   @@ -77,7 +80,7 @@
  TDEBUG_TRACE("Dirstatecache::get: dropping " << iter->hgroot);   delete iter->dstate;   iter->dstate = 0; - _cache.erase(iter); + cache().erase(iter);   return 0;   }   iter->tickcount = tc; @@ -110,7 +113,7 @@
  unsigned tc1 = GetTickCount();   unsigned delta = tc1 - tc0;   TDEBUG_TRACE("Dirstatecache::get: read done in " << delta << " ticks, " - << _cache.size() << " repos in cache"); + << cache().size() << " repos in cache");     iter->dstate_mtime = stat.mtime;   iter->dstate_size = stat.size;
 
19
20
21
 
22
23
24
 
36
37
38
 
 
39
40
41
 
19
20
21
22
23
24
25
 
37
38
39
40
41
42
43
44
@@ -19,6 +19,7 @@
 #define _DIRSTATECACHE_H    #include <string> +#include <list>    class Dirstate;   @@ -36,6 +37,8 @@
  E(): dstate(0), dstate_mtime(0), dstate_size(0), tickcount(0) {}   };   + static std::list<E>& cache(); +  public:   static Dirstate* get(const std::string& hgroot);  };