diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-21 01:54:03 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-22 14:29:04 +0300 |
commit | 21dc2816d6bb0a2a85e3a208830b629eb916ded0 (patch) | |
tree | 046dce1d360db51f00c6f293cd3454dcf4945622 /source/blender/blenlib/BLI_memblock.h | |
parent | 657165db94f14150416c2ee2221eeeafa32603f3 (diff) |
BLI_memblock: Refactor for faster iteration and allocation
Remove the clear allocation flag as it has little impact since there should
be very few allocation per redraw.
Make BLI_memblock_alloc and BLI_memblock_iterstep much more cache efficient
removing them almost entirely from performance profiles.
Diffstat (limited to 'source/blender/blenlib/BLI_memblock.h')
-rw-r--r-- | source/blender/blenlib/BLI_memblock.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_memblock.h b/source/blender/blenlib/BLI_memblock.h index 81dd2100362..c5ef26ffb91 100644 --- a/source/blender/blenlib/BLI_memblock.h +++ b/source/blender/blenlib/BLI_memblock.h @@ -35,16 +35,19 @@ struct BLI_memblock; typedef struct BLI_memblock BLI_memblock; typedef void (*MemblockValFreeFP)(void *val); -BLI_memblock *BLI_memblock_create(uint elem_size, - const bool clear_alloc) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +BLI_memblock *BLI_memblock_create(uint elem_size) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; void *BLI_memblock_alloc(BLI_memblock *mblk) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP valfreefp) ATTR_NONNULL(1); void BLI_memblock_destroy(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1); typedef struct BLI_memblock_iter { - BLI_memblock *mblk; - int current_index; - int elem_per_chunk; + void **chunk_list; + int cur_index; + int end_index; + int chunk_max_ofs; + int chunk_idx; + int elem_size; + int elem_ofs; } BLI_memblock_iter; void BLI_memblock_iternew(BLI_memblock *pool, BLI_memblock_iter *iter) ATTR_NONNULL(); |