diff options
author | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-05-31 16:49:05 +0000 |
---|---|---|
committer | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-05-31 16:49:05 +0000 |
commit | 9ba9a7bd0d4e58189352ca58f24d7f37b0ae9f20 (patch) | |
tree | ffc7229051b6aa18e4bb30fdd1328ed3bb4558ac | |
parent | 9fa0576e38559ebe7ff63a8d1161123b049a933b (diff) | |
download | vdr-plugin-live-9ba9a7bd0d4e58189352ca58f24d7f37b0ae9f20.tar.gz vdr-plugin-live-9ba9a7bd0d4e58189352ca58f24d7f37b0ae9f20.tar.bz2 |
- slight optimisation
-rwxr-xr-x | cache.h | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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(); |