From 7c9b1065895e0a6a12555075980d7a77d1dea8c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 2 Feb 2014 02:19:11 +1100 Subject: Smallhash: optimizations - remove static array used only for copying (use alloca on resize) - set SMSTACKSIZE to one of the values in 'hashsizes' since the full available size was never used. - ensure ~1.5x as many buckets as entries, was 3x which caused malloc's quite early on. --- source/blender/blenlib/BLI_smallhash.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'source/blender/blenlib/BLI_smallhash.h') diff --git a/source/blender/blenlib/BLI_smallhash.h b/source/blender/blenlib/BLI_smallhash.h index 07bd9975467..f394a224ca1 100644 --- a/source/blender/blenlib/BLI_smallhash.h +++ b/source/blender/blenlib/BLI_smallhash.h @@ -39,17 +39,16 @@ typedef struct { void *val; } SmallHashEntry; -/*how much stack space to use before dynamically allocating memory*/ -#define SMSTACKSIZE 64 +/* how much stack space to use before dynamically allocating memory. + * set to match one of the values in 'hashsizes' to avoid too many mallocs */ +#define SMSTACKSIZE 131 typedef struct SmallHash { - SmallHashEntry *buckets; - SmallHashEntry *buckets_stack; - SmallHashEntry *buckets_copy; - SmallHashEntry _buckets_stack[SMSTACKSIZE]; - SmallHashEntry _buckets_copy[SMSTACKSIZE]; unsigned int nbuckets; unsigned int nentries; unsigned int cursize; + + SmallHashEntry *buckets; + SmallHashEntry buckets_stack[SMSTACKSIZE]; } SmallHash; typedef struct { -- cgit v1.2.3