Commit: 868a4288abaf6ea0db1ba6314beccff425f6e14a
Author: Bastien Montagne
Date:   Sat Apr 4 13:17:43 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rB868a4288abaf6ea0db1ba6314beccff425f6e14a

FileBrowser: block caching: minor tweak (mostly needed in ae branch actually).

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

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 bda4477..01804fa 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1418,6 +1418,18 @@ int filelist_file_findpath(struct FileList *filelist, 
const char *filename)
        return -1;
 }
 
+/* Helper, low-level, it assumes cursor + size <= FILELIST_ENTRYCACHESIZE */
+static bool filelist_file_cache_block_do(struct FileList *filelist, const int 
start_index, const int size, int cursor)
+{
+       FileListEntryCache *cache = &filelist->filelist_cache;
+       FileListIntern *intern = &filelist->filelist_intern;
+
+       memcpy(&cache->block_entries[cursor], &intern->filtered[start_index],
+              sizeof(cache->block_entries[cursor]) * size);
+
+       return false;
+}
+
 /* Load in cache all entries "around" given index (as much as block cache may 
hold). */
 bool filelist_file_cache_block(struct FileList *filelist, const int index)
 {
@@ -1455,8 +1467,9 @@ bool filelist_file_cache_block(struct FileList *filelist, 
const int index)
        //              printf("Full Recaching!\n");
 
                        /* New cached block does not overlap existing one, 
simple. */
-                       memcpy(cache->block_entries, 
&filelist->filelist_intern.filtered[start_index],
-                                  sizeof(cache->block_entries[0]) * (end_index 
- start_index));
+                       if (!filelist_file_cache_block_do(filelist, 
start_index, end_index - start_index, 0)) {
+                               return false;
+                       }
 
                        if (cache->previews_pool) {
                                filelist_cache_previews_clear(cache);
@@ -1494,11 +1507,13 @@ bool filelist_file_cache_block(struct FileList 
*filelist, const int index)
                                }
 
                                if (size2) {
-                                       memcpy(&cache->block_entries[idx2], 
&filelist->filelist_intern.filtered[end_index - size2],
-                                                  
sizeof(cache->block_entries[0]) * size2);
+                                       if 
(!filelist_file_cache_block_do(filelist, end_index - size2, size2, idx2)) {
+                                               return false;
+                                       }
+                               }
+                               if (!filelist_file_cache_block_do(filelist, 
end_index - size1 - size2, size1, idx1)) {
+                                       return false;
                                }
-                               memcpy(&cache->block_entries[idx1], 
&filelist->filelist_intern.filtered[end_index - size1 - size2],
-                                          sizeof(cache->block_entries[0]) * 
size1);
                        }
                        cache->block_end_index = end_index;
 
@@ -1517,18 +1532,19 @@ bool filelist_file_cache_block(struct FileList 
*filelist, const int index)
                                        size2 -= size1;
                                        idx2 = 0;
                                        idx1 = FILELIST_ENTRYCACHESIZE - size1;
-
                                }
                                else {
                                        idx1 = cache->block_cursor - size1;
                                }
 
                                if (size2) {
-                                       memcpy(&cache->block_entries[idx2], 
&filelist->filelist_intern.filtered[start_index + size1],
-                                                  
sizeof(cache->block_entries[0]) * size2);
+                                       if 
(!filelist_file_cache_block_do(filelist, start_index + size1, size2, idx2)) {
+                                               return false;
+                                       }
+                               }
+                               if (!filelist_file_cache_block_do(filelist, 
start_index, size1, idx1)) {
+                                       return false;
                                }
-                               memcpy(&cache->block_entries[idx1], 
&filelist->filelist_intern.filtered[start_index],
-                                          sizeof(cache->block_entries[0]) * 
size1);
 
                                cache->block_cursor = idx1;
                        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to