[Scummvm-cvs-logs] SF.net SVN: scummvm:[35576] scummvm/trunk/common

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Dec 27 18:16:51 CET 2008


Revision: 35576
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35576&view=rev
Author:   fingolfin
Date:     2008-12-27 17:16:48 +0000 (Sat, 27 Dec 2008)

Log Message:
-----------
Moved addDirectory from SearchManager to SearchSet; changed several places from using '++it' instead of 'it++' to iterate over a list (this is more efficient)

Modified Paths:
--------------
    scummvm/trunk/common/archive.cpp
    scummvm/trunk/common/archive.h

Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp	2008-12-27 17:09:28 UTC (rev 35575)
+++ scummvm/trunk/common/archive.cpp	2008-12-27 17:16:48 UTC (rev 35576)
@@ -55,7 +55,7 @@
 	lowercasePattern.toLowercase();
 
 	ArchiveMemberList::iterator it = allNames.begin();
-	for ( ; it != allNames.end(); it++) {
+	for ( ; it != allNames.end(); ++it) {
 		if ((*it)->getName().matchString(lowercasePattern)) {
 			list.push_back(*it);
 			matches++;
@@ -201,7 +201,7 @@
 	node.getChildren(list, FSNode::kListAll, false);
 
 	FSList::iterator it = list.begin();
-	for ( ; it != list.end(); it++) {
+	for ( ; it != list.end(); ++it) {
 		String name = prefix + it->getName();
 
 		// don't touch name as it might be used for warning messages
@@ -297,7 +297,7 @@
 
 	int matches = 0;
 	NodeCache::iterator it = _fileCache.begin();
-	for ( ; it != _fileCache.end(); it++) {
+	for ( ; it != _fileCache.end(); ++it) {
 		if (matchPath(it->_key.c_str(), lowercasePattern.c_str())) {
 			list.push_back(ArchiveMemberPtr(new FSDirectoryMember(it->_value)));
 			matches++;
@@ -328,7 +328,7 @@
 
 SearchSet::ArchiveNodeList::iterator SearchSet::find(const String &name) const {
 	ArchiveNodeList::iterator it = _list.begin();
-	for ( ; it != _list.end(); it++) {
+	for ( ; it != _list.end(); ++it) {
 		if (it->_name == name)
 			break;
 	}
@@ -342,7 +342,7 @@
 */
 void SearchSet::insert(const Node &node) {
 	ArchiveNodeList::iterator it = _list.begin();
-	for ( ; it != _list.end(); it++) {
+	for ( ; it != _list.end(); ++it) {
 		if (it->_priority < node._priority)
 			break;
 	}
@@ -361,6 +361,19 @@
 
 }
 
+void SearchSet::addDirectory(const String &name, const String &directory, int priority, int depth) {
+	FSNode dir(directory);
+	addDirectory(name, dir, priority, depth);
+}
+
+void SearchSet::addDirectory(const String &name, const FSNode &dir, int priority, int depth) {
+	if (!dir.exists() || !dir.isDirectory())
+		return;
+
+	add(name, new FSDirectory(dir, depth), priority);
+}
+
+
 void SearchSet::remove(const String &name) {
 	ArchiveNodeList::iterator it = find(name);
 	if (it != _list.end()) {
@@ -404,7 +417,7 @@
 		return false;
 
 	ArchiveNodeList::iterator it = _list.begin();
-	for ( ; it != _list.end(); it++) {
+	for ( ; it != _list.end(); ++it) {
 		if (it->_arc->hasFile(name))
 			return true;
 	}
@@ -416,7 +429,7 @@
 	int matches = 0;
 
 	ArchiveNodeList::iterator it = _list.begin();
-	for ( ; it != _list.end(); it++)
+	for ( ; it != _list.end(); ++it)
 		matches += it->_arc->listMatchingMembers(list, pattern);
 
 	return matches;
@@ -426,7 +439,7 @@
 	int matches = 0;
 
 	ArchiveNodeList::iterator it = _list.begin();
-	for ( ; it != _list.end(); it++)
+	for ( ; it != _list.end(); ++it)
 		matches += it->_arc->listMembers(list);
 
 	return matches;
@@ -437,7 +450,7 @@
 		return ArchiveMemberPtr();
 
 	ArchiveNodeList::iterator it = _list.begin();
-	for ( ; it != _list.end(); it++) {
+	for ( ; it != _list.end(); ++it) {
 		if (it->_arc->hasFile(name))
 			return it->_arc->getMember(name);
 	}
@@ -450,7 +463,7 @@
 		return 0;
 
 	ArchiveNodeList::iterator it = _list.begin();
-	for ( ; it != _list.end(); it++) {
+	for ( ; it != _list.end(); ++it) {
 		if (it->_arc->hasFile(name))
 			return it->_arc->openFile(name);
 	}
@@ -465,18 +478,6 @@
 	clear();	// Force a reset
 }
 
-void SearchManager::addDirectory(const String &name, const String &directory, int priority, int depth) {
-	FSNode dir(directory);
-	addDirectory(name, dir, priority, depth);
-}
-
-void SearchManager::addDirectory(const String &name, const FSNode &dir, int priority, int depth) {
-	if (!dir.exists() || !dir.isDirectory())
-		return;
-
-	add(name, new FSDirectory(dir, depth), priority);
-}
-
 void SearchManager::clear() {
 	SearchSet::clear();
 

Modified: scummvm/trunk/common/archive.h
===================================================================
--- scummvm/trunk/common/archive.h	2008-12-27 17:09:28 UTC (rev 35575)
+++ scummvm/trunk/common/archive.h	2008-12-27 17:16:48 UTC (rev 35576)
@@ -265,6 +265,16 @@
 	void add(const String& name, Archive *arch, int priority = 0, bool autoFree = true);
 
 	/**
+	 * Create and add a FSDirectory by name
+	 */
+	void addDirectory(const String &name, const String &directory, int priority = 0, int depth = 1);
+
+	/**
+	 * Create and add a FSDirectory by FSNode
+	 */
+	void addDirectory(const String &name, const FSNode &directory, int priority = 0, int depth = 1);
+
+	/**
 	 * Remove an archive from the searchable set.
 	 */
 	void remove(const String& name);
@@ -302,16 +312,6 @@
 public:
 
 	/**
-	 * Create and add a FSDirectory by name
-	 */
-	void addDirectory(const String &name, const String &directory, int priority = 0, int depth = 1);
-
-	/**
-	 * Create and add a FSDirectory by FSNode
-	 */
-	void addDirectory(const String &name, const FSNode &directory, int priority = 0, int depth = 1);
-
-	/**
 	 * Resets the search manager to the default list of search paths (system
 	 * specific dirs + current dir).
 	 */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list