summaryrefslogtreecommitdiff
path: root/src/ModuleCache.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-05-27 22:28:29 (GMT)
committerMarius Kintel <marius@kintel.net>2013-05-27 22:28:29 (GMT)
commit4bc18dc6802906738eb9f0d75ea063f271a0c9b7 (patch)
tree1940911c3b43af1d290abd7fc2e8f65b706d783c /src/ModuleCache.cc
parent84e918da7d35ba7e4a74951e803f5aa9bf24bb07 (diff)
Don't auto-reload missing files, reduce warning output from periodically called functions
Diffstat (limited to 'src/ModuleCache.cc')
-rw-r--r--src/ModuleCache.cc29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc
index 505015e..0e443e8 100644
--- a/src/ModuleCache.cc
+++ b/src/ModuleCache.cc
@@ -30,34 +30,37 @@ ModuleCache *ModuleCache::inst = NULL;
*/
FileModule *ModuleCache::evaluate(const std::string &filename)
{
+ bool shouldCompile = true;
FileModule *lib_mod = NULL;
// Create cache ID
struct stat st;
memset(&st, 0, sizeof(struct stat));
- stat(filename.c_str(), &st);
+ bool valid = (stat(filename.c_str(), &st) == 0);
std::string cache_id = str(boost::format("%x.%x") % st.st_mtime % st.st_size);
// Lookup in cache
- if (this->entries.find(filename) != this->entries.end() &&
- this->entries[filename].cache_id == cache_id) {
-#ifdef DEBUG
-// Causes too much debug output
-// PRINTB("Using cached library: %s (%s)", filename % cache_id);
-#endif
+ if (this->entries.find(filename) != this->entries.end()) {
lib_mod = &(*this->entries[filename].module);
-
- BOOST_FOREACH(const FileModule::IncludeContainer::value_type &include, lib_mod->includes) {
- if (lib_mod->include_modified(include.second)) {
- lib_mod = NULL;
- break;
+ if (this->entries[filename].cache_id == cache_id) {
+ shouldCompile = false;
+
+ BOOST_FOREACH(const FileModule::IncludeContainer::value_type &include, lib_mod->includes) {
+ if (lib_mod->include_modified(include.second)) {
+ lib_mod = NULL;
+ shouldCompile = true;
+ break;
+ }
}
}
}
+ else {
+ shouldCompile = valid;
+ }
// If cache lookup failed (non-existing or old timestamp), compile module
- if (!lib_mod) {
+ if (shouldCompile) {
#ifdef DEBUG
if (this->entries.find(filename) != this->entries.end()) {
PRINTB("Recompiling cached library: %s (%s)", filename % cache_id);
contact: Jan Huwald // Impressum