summaryrefslogtreecommitdiff
path: root/src/ModuleCache.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-05-20 04:31:18 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-05-20 04:31:18 (GMT)
commit8a83e334abceda6f5c119872f922da7cc99c7210 (patch)
treebbe1f2e20fa599ebfad4f89aebd5e46905630ead /src/ModuleCache.cc
parent77a598ab7267d04f0b1fc0277e0314c3780313c0 (diff)
try to refactor the 'is_modified( includefile )' code
Diffstat (limited to 'src/ModuleCache.cc')
-rw-r--r--src/ModuleCache.cc23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc
index 8a082af..030cfa0 100644
--- a/src/ModuleCache.cc
+++ b/src/ModuleCache.cc
@@ -14,35 +14,26 @@
#include <time.h>
#include <sys/stat.h>
+//#include "parsersettings.h"
/*!
FIXME: Implement an LRU scheme to avoid having an ever-growing module cache
*/
ModuleCache *ModuleCache::inst = NULL;
-#include <iostream>
-
-static bool is_modified(const std::string &filename, const time_t &mtime)
-{
- std::cout << "cache ismod " << filename << "\n";
- struct stat st;
- memset(&st, 0, sizeof(struct stat));
- stat(filename.c_str(), &st);
- return (st.st_mtime > mtime);
-}
FileModule *ModuleCache::evaluate(const std::string &filename)
{
std::cout << "modcache eval" << filename << "\n";
FileModule *lib_mod = NULL;
- // Create cache ID
+ // Create cache ID
struct stat st;
memset(&st, 0, sizeof(struct stat));
stat(filename.c_str(), &st);
std::string cache_id = str(boost::format("%x.%x") % st.st_mtime % st.st_size);
- // Lookup in cache
+ // Lookup in cache
if (this->entries.find(filename) != this->entries.end() &&
this->entries[filename].cache_id == cache_id) {
#ifdef DEBUG
@@ -51,15 +42,15 @@ FileModule *ModuleCache::evaluate(const std::string &filename)
#endif
lib_mod = &(*this->entries[filename].module);
- BOOST_FOREACH(const FileModule::IncludeContainer::value_type &item, lib_mod->includes) {
- if (is_modified(item.first, item.second)) {
+ BOOST_FOREACH(const FileModule::IncludeContainer::value_type &include, lib_mod->includes) {
+ if (lib_mod->include_modified(include.second)) {
lib_mod = NULL;
break;
}
}
}
- // If cache lookup failed (non-existing or old timestamp), compile module
+ // If cache lookup failed (non-existing or old timestamp), compile module
if (!lib_mod) {
#ifdef DEBUG
if (this->entries.find(filename) != this->entries.end()) {
@@ -94,7 +85,7 @@ FileModule *ModuleCache::evaluate(const std::string &filename)
if (lib_mod) {
// We defer deletion so we can ensure that the new module won't
- // have the same address as the old
+ // have the same address as the old
delete oldmodule;
this->entries[filename].module = lib_mod;
} else {
contact: Jan Huwald // Impressum