author | zecke <zecke> | 2005-02-08 23:00:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-08 23:00:37 (UTC) |
commit | 80144c63f04e798b10a966402f235d236e3e540f (patch) (unidiff) | |
tree | f3d986c4f58a8730b4a30008aadf97b70ef4c9ce | |
parent | f24d8318de30b47ec8f877293fd175deaa0b914c (diff) | |
download | opie-80144c63f04e798b10a966402f235d236e3e540f.zip opie-80144c63f04e798b10a966402f235d236e3e540f.tar.gz opie-80144c63f04e798b10a966402f235d236e3e540f.tar.bz2 |
Remove the debug output of the ConfigCache
-rw-r--r-- | library/config.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/library/config.cpp b/library/config.cpp index e9cae4c..72bd4d2 100644 --- a/library/config.cpp +++ b/library/config.cpp | |||
@@ -118,65 +118,64 @@ private: | |||
118 | ConfigCache* ConfigCache::m_inst = 0; | 118 | ConfigCache* ConfigCache::m_inst = 0; |
119 | /* | 119 | /* |
120 | * get destroyed when qApp gets destroyed | 120 | * get destroyed when qApp gets destroyed |
121 | */ | 121 | */ |
122 | ConfigCache::ConfigCache() : QObject( qApp ), m_totalSize( 0 ), m_tid( 0 ) {} | 122 | ConfigCache::ConfigCache() : QObject( qApp ), m_totalSize( 0 ), m_tid( 0 ) {} |
123 | ConfigCache* ConfigCache::instance() { | 123 | ConfigCache* ConfigCache::instance() { |
124 | if ( !m_inst ) | 124 | if ( !m_inst ) |
125 | m_inst = new ConfigCache(); | 125 | m_inst = new ConfigCache(); |
126 | 126 | ||
127 | return m_inst; | 127 | return m_inst; |
128 | } | 128 | } |
129 | 129 | ||
130 | void ConfigCache::remove( const QString& fileName ) { | 130 | void ConfigCache::remove( const QString& fileName ) { |
131 | QMap<QString, ConfigData>::Iterator it = m_cached.find( fileName ); | 131 | QMap<QString, ConfigData>::Iterator it = m_cached.find( fileName ); |
132 | 132 | ||
133 | if ( it == m_cached.end() ) | 133 | if ( it == m_cached.end() ) |
134 | return; | 134 | return; |
135 | 135 | ||
136 | m_totalSize -= (*it).size; | 136 | m_totalSize -= (*it).size; |
137 | m_cached.remove( it ); | 137 | m_cached.remove( it ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void ConfigCache::removeLru() { | 140 | void ConfigCache::removeLru() { |
141 | QMap<QString, ConfigData>::Iterator it = m_cached.begin(); | 141 | QMap<QString, ConfigData>::Iterator it = m_cached.begin(); |
142 | QMap<QString, ConfigData>::Iterator lru = it; | 142 | QMap<QString, ConfigData>::Iterator lru = it; |
143 | ++it; | 143 | ++it; |
144 | for (; it != m_cached.end(); ++it) | 144 | for (; it != m_cached.end(); ++it) |
145 | if ((*it).used.tv_sec < (*lru).used.tv_sec || | 145 | if ((*it).used.tv_sec < (*lru).used.tv_sec || |
146 | ((*it).used.tv_sec == (*lru).used.tv_sec && | 146 | ((*it).used.tv_sec == (*lru).used.tv_sec && |
147 | (*it).used.tv_usec < (*lru).used.tv_usec)) | 147 | (*it).used.tv_usec < (*lru).used.tv_usec)) |
148 | lru = it; | 148 | lru = it; |
149 | 149 | ||
150 | qWarning( "Removing item" ); | ||
151 | m_totalSize -= (*lru).size; | 150 | m_totalSize -= (*lru).size; |
152 | m_cached.remove(lru); | 151 | m_cached.remove(lru); |
153 | } | 152 | } |
154 | 153 | ||
155 | void ConfigCache::timerEvent( QTimerEvent* ) { | 154 | void ConfigCache::timerEvent( QTimerEvent* ) { |
156 | while ( m_totalSize > CONFIG_CACHE_SIZE ) | 155 | while ( m_totalSize > CONFIG_CACHE_SIZE ) |
157 | removeLru(); | 156 | removeLru(); |
158 | 157 | ||
159 | killTimer(m_tid); | 158 | killTimer(m_tid); |
160 | m_tid = 0; | 159 | m_tid = 0; |
161 | } | 160 | } |
162 | 161 | ||
163 | void ConfigCache::insert( const QString& fileName, const ConfigGroupMap& cfg, | 162 | void ConfigCache::insert( const QString& fileName, const ConfigGroupMap& cfg, |
164 | const ConfigPrivate* _priv ) { | 163 | const ConfigPrivate* _priv ) { |
165 | 164 | ||
166 | 165 | ||
167 | struct stat sbuf; | 166 | struct stat sbuf; |
168 | ::stat( QFile::encodeName(fileName), &sbuf ); | 167 | ::stat( QFile::encodeName(fileName), &sbuf ); |
169 | if ( static_cast<unsigned int>(sbuf.st_size) >= CONFIG_CACHE_SIZE>>1) | 168 | if ( static_cast<unsigned int>(sbuf.st_size) >= CONFIG_CACHE_SIZE>>1) |
170 | return; | 169 | return; |
171 | 170 | ||
172 | /* | 171 | /* |
173 | * remove the old version and use the new one | 172 | * remove the old version and use the new one |
174 | */ | 173 | */ |
175 | ConfigPrivate priv = _priv ? *_priv : ConfigPrivate(); | 174 | ConfigPrivate priv = _priv ? *_priv : ConfigPrivate(); |
176 | ConfigData data( cfg, priv, sbuf ); | 175 | ConfigData data( cfg, priv, sbuf ); |
177 | m_totalSize += data.size; | 176 | m_totalSize += data.size; |
178 | 177 | ||
179 | remove( fileName ); | 178 | remove( fileName ); |
180 | m_cached.insert( fileName, data ); | 179 | m_cached.insert( fileName, data ); |
181 | 180 | ||
182 | /* | 181 | /* |