Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-02-01 19:19:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-01 19:24:48 +0400
commit7c9b1065895e0a6a12555075980d7a77d1dea8c7 (patch)
tree1d7516889824f82a9f0f9fcd56461575a84cff3e /source/blender/blenlib/BLI_smallhash.h
parenta1a0ebbf490fd36d893ad5b0a37e099f3d035eac (diff)
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.
Diffstat (limited to 'source/blender/blenlib/BLI_smallhash.h')
-rw-r--r--source/blender/blenlib/BLI_smallhash.h13
1 files changed, 6 insertions, 7 deletions
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 {