[Bf-blender-cvs] [9c90c55] master: SpaceFile: rework filelist_find, was looping way too much.

Bastien Montagne noreply at git.blender.org
Mon Feb 9 10:14:50 CET 2015


Commit: 9c90c559fe31c65cb9e5f5248772395992d7c429
Author: Bastien Montagne
Date:   Mon Feb 9 10:10:20 2015 +0100
Branches: master
https://developer.blender.org/rB9c90c559fe31c65cb9e5f5248772395992d7c429

SpaceFile: rework filelist_find, was looping way too much.

===================================================================

M	source/blender/editors/space_file/filelist.c

===================================================================

diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index edf0bb0..f0180c3 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -761,29 +761,20 @@ struct direntry *filelist_file(struct FileList *filelist, int index)
 
 int filelist_find(struct FileList *filelist, const char *filename)
 {
-	int index = -1;
-	int i;
 	int fidx = -1;
 	
 	if (!filelist->fidx) 
 		return fidx;
 
-	
-	for (i = 0; i < filelist->numfiles; ++i) {
-		/* not dealing with user input so don't need BLI_path_cmp */
-		if (STREQ(filelist->filelist[i].relname, filename)) {
-			index = i;
-			break;
-		}
-	}
+	for (fidx = 0; fidx < filelist->numfiltered; fidx++) {
+		int index = filelist->fidx[fidx];
 
-	for (i = 0; i < filelist->numfiltered; ++i) {
-		if (filelist->fidx[i] == index) {
-			fidx = i;
-			break;
+		if (STREQ(filelist->filelist[index].relname, filename)) {
+			return fidx;
 		}
 	}
-	return fidx;
+
+	return -1;
 }
 
 /* would recognize .blend as well */




More information about the Bf-blender-cvs mailing list