diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-02-09 12:10:20 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-02-09 12:10:20 +0300 |
commit | 9c90c559fe31c65cb9e5f5248772395992d7c429 (patch) | |
tree | 3f7223e90db033ba05ca90ca35ecf84c9d81e21a /source/blender/editors/space_file/filelist.c | |
parent | 12ed439d8ef9e40234d31b93fa199bcfee3365f6 (diff) |
SpaceFile: rework filelist_find, was looping way too much.
Diffstat (limited to 'source/blender/editors/space_file/filelist.c')
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index edf0bb025c7..f0180c3c841 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 */ |