From 6470ee1a051a4e4fac014162c0d9632487093d08 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 5 Jan 2010 00:17:29 +0000 Subject: Removed some silly debugging output and added the StatCache, it turns out this doesn't matter, at least on linux...but...it's a nice idea? I dunno. --- src/conditionfiletime.cpp | 17 ++++++++--------- src/runner.cpp | 4 ++++ src/statcache.cpp | 28 ++++++++++++++++++++++++++++ src/statcache.h | 24 ++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 src/statcache.cpp create mode 100644 src/statcache.h diff --git a/src/conditionfiletime.cpp b/src/conditionfiletime.cpp index 148ffac..abcb3f3 100644 --- a/src/conditionfiletime.cpp +++ b/src/conditionfiletime.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "statcache.h" #include using namespace Bu; @@ -18,6 +19,7 @@ ConditionFileTime::~ConditionFileTime() bool ConditionFileTime::shouldExec( class Runner &r, Target &rTarget ) { + StatCache &Stat = StatCache::getInstance(); for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ ) { if( access( (*j).getStr(), F_OK ) ) @@ -30,22 +32,20 @@ bool ConditionFileTime::shouldExec( class Runner &r, Target &rTarget ) } } - time_t tOut = 0; - struct stat s; + time_t tOut = 0, tmp; for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ ) { - stat( (*j).getStr(), &s ); - if( tOut == 0 || tOut > s.st_mtime ) + tmp = Stat.mtime( *j ); + if( tOut == 0 || tOut > tmp ) { - tOut = s.st_mtime; + tOut = tmp; } } for( StrList::const_iterator j = rTarget.getInputList().begin(); j; j++ ) { - stat( (*j).getStr(), &s ); - if( tOut < s.st_mtime ) + if( tOut < Stat.mtime( *j ) ) { //sio << "-- Target processed because '" << *j // << "' is newer than output." << sio.nl; @@ -57,8 +57,7 @@ bool ConditionFileTime::shouldExec( class Runner &r, Target &rTarget ) for( StrList::const_iterator j = rTarget.getRequiresList().begin(); j; j++ ) { - stat( (*j).getStr(), &s ); - if( tOut < s.st_mtime ) + if( tOut < Stat.mtime( *j ) ) { //sio << "-- Target processed because '" << *j // << "' is newer than output." << sio.nl; diff --git a/src/runner.cpp b/src/runner.cpp index ace9ce9..947f2f5 100644 --- a/src/runner.cpp +++ b/src/runner.cpp @@ -417,6 +417,10 @@ Variable Runner::run( AstBranch::NodeList::const_iterator n ) ); } break; + + case AstNode::typePushPrefix: + case AstNode::typePopPrefix: + break; /* case AstNode::typeCondition: if( pCurTarget ) diff --git a/src/statcache.cpp b/src/statcache.cpp new file mode 100644 index 0000000..3f5c21f --- /dev/null +++ b/src/statcache.cpp @@ -0,0 +1,28 @@ +#include "statcache.h" + +#include + +#include + +StatCache::StatCache() +{ +} + +StatCache::~StatCache() +{ +} + +time_t StatCache::mtime( const Bu::FString &sFileName ) +{ + try + { + return hMTime.get( sFileName ); + } catch( ... ) + { + struct stat s; + stat( sFileName.getStr(), &s ); + hMTime.insert( sFileName, s.st_mtime ); + return s.st_mtime; + } +} + diff --git a/src/statcache.h b/src/statcache.h new file mode 100644 index 0000000..e081ec3 --- /dev/null +++ b/src/statcache.h @@ -0,0 +1,24 @@ +#ifndef STAT_CACHE_H +#define STAT_CACHE_H + +#include +#include +#include +#include + +class StatCache : public Bu::Singleton +{ +friend class Bu::Singleton; +private: + StatCache(); + virtual ~StatCache(); + +public: + time_t mtime( const Bu::FString &sFileName ); + +private: + typedef Bu::Hash TimeHash; + TimeHash hMTime; +}; + +#endif -- cgit v1.2.3