← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3081: the file list cache counter doesn't have to be so big

 

------------------------------------------------------------
revno: 3081
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2012-10-20 14:02:25 +0200
message:
  the file list cache counter doesn't have to be so big
modified:
  win32/DirectoryListingFrame.cpp
  win32/TypedTree.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp	2012-10-16 17:39:17 +0000
+++ win32/DirectoryListingFrame.cpp	2012-10-20 12:02:25 +0000
@@ -416,24 +416,24 @@
 namespace {
 	/* items cached by all open file lists. caching can take up a lot of memory so we use this
 	counter to keep tabs on the caches and make sure they don't grow too big. */
-	atomic<uint64_t> cacheCount(0);
+	atomic<uint32_t> cacheCount(0);
 
 	/* minimum amount of items to require a cache. this helps skip directories that don't have many
 	files: file information for small directories is easy to build up on-the-fly without inducing
 	any GUI freeze, so we don't cache these small directories. this value can be increased as long
 	as displaying a directory with cacheLowerBound files doesn't freeze the GUI for too long. */
-	const uint64_t cacheLowerBound = 1024;
+	const uint32_t cacheLowerBound = 1024;
 
 	/* maximum amount of items all file list caches can contain. we aim for 500MB max on x86 and
 	1GB max on x64, with the assumption that one cached item occupies around 1KB. */
 #ifdef _WIN64
-	const uint64_t maxCacheCount = 1024 * 1024;
+	const uint32_t maxCacheCount = 1024 * 1024;
 #else
-	const uint64_t maxCacheCount = 512 * 1024;
+	const uint32_t maxCacheCount = 512 * 1024;
 #endif
 
 	template<typename T> bool canCache(T items) {
-		return items > cacheLowerBound && cacheCount + static_cast<uint64_t>(items) < maxCacheCount;
+		return items > cacheLowerBound && cacheCount + static_cast<uint32_t>(items) < maxCacheCount;
 	}
 }
 

=== modified file 'win32/TypedTree.h'
--- win32/TypedTree.h	2012-10-19 10:40:17 +0000
+++ win32/TypedTree.h	2012-10-20 12:02:25 +0000
@@ -117,7 +117,15 @@
 		this->BaseType::clear();
 	}
 
-	void erase(HTREEITEM item) { if(managed) delete getData(item); this->BaseType::erase(item); }
+	void erase(HTREEITEM item) {
+		if(managed) {
+			auto data = getData(item);
+			this->BaseType::erase(item);
+			delete data;
+		} else {
+			this->BaseType::erase(item);
+		}
+	}
 
 private:
 	void handleDisplay(NMTVDISPINFO& data) {