summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-05-31 16:49:05 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-05-31 16:49:05 +0000
commit9ba9a7bd0d4e58189352ca58f24d7f37b0ae9f20 (patch)
treeffc7229051b6aa18e4bb30fdd1328ed3bb4558ac
parent9fa0576e38559ebe7ff63a8d1161123b049a933b (diff)
downloadvdr-plugin-live-9ba9a7bd0d4e58189352ca58f24d7f37b0ae9f20.tar.gz
vdr-plugin-live-9ba9a7bd0d4e58189352ca58f24d7f37b0ae9f20.tar.bz2
- slight optimisation
-rwxr-xr-xcache.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/cache.h b/cache.h
index 0b81cf5..4b78ee5 100755
--- a/cache.h
+++ b/cache.h
@@ -68,16 +68,25 @@ public:
m_currentWeight -= result->weight();
m_values.erase( it->second );
- m_lookup.erase( it );
+ //m_lookup.erase( it );
}
- if ( !result->load() )
+ if ( !result->load() ) {
+ if ( it != m_lookup.end() )
+ m_lookup.erase( it );
return ptr_type();
+ }
// put new object into cache
if ( result->weight() < m_maxWeight ) {
m_currentWeight += result->weight();
- m_lookup.insert( std::make_pair( key, m_values.insert( m_values.begin(), std::make_pair( key, result ) ) ) );
+
+ typename ValueList::iterator element = m_values.insert( m_values.begin(), std::make_pair( key, result ) );
+ if ( it != m_lookup.end() )
+ it->second = element;
+ else
+ m_lookup.insert( std::make_pair( key, element ) );
+
while ( m_currentWeight > m_maxWeight ) {
value_type& value = m_values.back();
m_currentWeight -= value.second->weight();