Changeset 1df8964a92f5…
Parent 20e880cce2d0…
by
Changes to one file · Browse files at 1df8964a92f5 Showing diff from parent 20e880cce2d0 Diff from another changeset...
@@ -185,8 +185,9 @@ const dirstate* dstate;
__time64_t mtime;
std::string hgroot;
+ unsigned tickcount;
- entry(): dstate(0), mtime(0) {}
+ entry(): dstate(0), mtime(0), tickcount(0) {}
};
typedef std::list<entry>::iterator Iter;
@@ -202,17 +203,6 @@
const dirstate* dirstatecache::get(const std::string& hgroot)
{
- std::string path = hgroot;
- path += "/.hg/dirstate";
-
- struct _stat stat;
-
- if (0 != lstat(path.c_str(), stat))
- {
- TDEBUG_TRACE("dirstatecache::get: lstat(" << path <<") fails");
- return 0;
- }
-
Iter iter = _cache.begin();
for (;iter != _cache.end(); ++iter)
@@ -221,6 +211,8 @@ break;
}
+ bool isnew = false;
+
if (iter == _cache.end())
{
if (_cache.size() >= 10)
@@ -234,9 +226,30 @@ e.hgroot = hgroot;
_cache.push_front(e);
iter = _cache.begin();
+ isnew = true;
}
- if (iter->mtime < stat.st_mtime)
+ unsigned tc = GetTickCount();
+
+ std::string path = hgroot +"/.hg/dirstate";
+
+ struct _stat stat;
+
+ bool stat_done = false;
+
+ if (isnew || (tc - iter->tickcount) > 500)
+ {
+ if (0 != lstat(path.c_str(), stat))
+ {
+ TDEBUG_TRACE("dirstatecache::get: lstat(" << path <<") failed");
+ return 0;
+ }
+ iter->tickcount = tc;
+ stat_done = true;
+ TDEBUG_TRACE("dirstatecache::get: lstat(" << path <<") ok ");
+ }
+
+ if (stat_done && iter->mtime < stat.st_mtime)
{
iter->mtime = stat.st_mtime;
if (iter->dstate) {
|
Loading...