diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-03-02 03:12:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-03-02 03:18:56 +0300 |
commit | 0658659f74ad134bddbc982f7e1de0ff9b8bda66 (patch) | |
tree | e7a2ad5b5e63cc6dc7236e03e87148557121337f /source/blender/blenkernel/intern | |
parent | bac98199e956674473525bdb2504cf2e3b2c1417 (diff) |
GHash: BLI_ghash_ensure_p_ex now takes a pointer-to-key arg
This is an alternative to passing a copy callback which is some times inconvenient.
Instead the caller can write to the key - needed when the key is duplicated memory.
Allows for minor optimization in ghash/gset use.
Also add BLI_gset_ensure_p_ex
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/icons.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 45ebada4d81..f3e86b44459 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -273,9 +273,10 @@ PreviewImage *BKE_previewimg_cached_get(const char *name) PreviewImage *BKE_previewimg_cached_ensure(const char *name) { PreviewImage *prv = NULL; - void **prv_p; + void **key_p, **prv_p; - if (!BLI_ghash_ensure_p_ex(gCachedPreviews, name, &prv_p, (GHashKeyCopyFP)BLI_strdup)) { + if (!BLI_ghash_ensure_p_ex(gCachedPreviews, name, &key_p, &prv_p)) { + *key_p = BLI_strdup(name); *prv_p = BKE_previewimg_create(); } prv = *prv_p; |