diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-09-25 00:15:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-09-25 00:16:37 +0400 |
commit | 6f2f80887b10f6a704a7394f0580e6ee39ea611d (patch) | |
tree | f27b5f9f2d009e2784fc058c22581a95b9d834da /source/blender/blenkernel/intern | |
parent | faaf0c719f3310759bf5f2c9be76f6788a923364 (diff) |
GHash: use bool for comparison (simplify compare)
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/seqcache.c | 87 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/treehash.c | 2 |
6 files changed, 24 insertions, 102 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 23ffa53a096..3aba16ddc38 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2717,7 +2717,7 @@ static unsigned int poly_gset_hash_fn(const void *key) return pk->hash_sum; } -static int poly_gset_compare_fn(const void *k1, const void *k2) +static bool poly_gset_compare_fn(const void *k1, const void *k2) { const PolyKey *pk1 = k1; const PolyKey *pk2 = k2; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 805c1250c5d..b57d0143b9b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -120,12 +120,12 @@ static unsigned int imagecache_hashhash(const void *key_v) return key->index; } -static int imagecache_hashcmp(const void *a_v, const void *b_v) +static bool imagecache_hashcmp(const void *a_v, const void *b_v) { const ImageCacheKey *a = (ImageCacheKey *) a_v; const ImageCacheKey *b = (ImageCacheKey *) b_v; - return a->index - b->index; + return (a->index != b->index); } static void imagecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags) diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 35bf453c328..e28adb7c0e0 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -406,27 +406,14 @@ static unsigned int moviecache_hashhash(const void *keyv) return rval; } -static int moviecache_hashcmp(const void *av, const void *bv) +static bool moviecache_hashcmp(const void *av, const void *bv) { const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey *)av; const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey *)bv; - if (a->framenr < b->framenr) - return -1; - else if (a->framenr > b->framenr) - return 1; - - if (a->proxy < b->proxy) - return -1; - else if (a->proxy > b->proxy) - return 1; - - if (a->render_flag < b->render_flag) - return -1; - else if (a->render_flag > b->render_flag) - return 1; - - return 0; + return ((a->framenr != b->framenr) || + (a->proxy != b->proxy) || + (a->render_flag != b->render_flag)); } static void *moviecache_getprioritydata(void *key_v) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 0f86b551092..3a7bfb03e07 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2682,16 +2682,12 @@ static unsigned int node_instance_hash_key(const void *key) return ((const bNodeInstanceKey *)key)->value; } -static int node_instance_hash_key_cmp(const void *a, const void *b) +static bool node_instance_hash_key_cmp(const void *a, const void *b) { unsigned int value_a = ((const bNodeInstanceKey *)a)->value; unsigned int value_b = ((const bNodeInstanceKey *)b)->value; - if (value_a == value_b) - return 0; - else if (value_a < value_b) - return -1; - else - return 1; + + return (value_a != value_b); } bNodeInstanceHash *BKE_node_instance_hash_new(const char *info) diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 97062f728c5..4268b33cb14 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -69,58 +69,15 @@ static struct SeqPreprocessCache *preprocess_cache = NULL; static void preprocessed_cache_destruct(void); -static int seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b) +static bool seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b) { - if (a->preview_render_size < b->preview_render_size) { - return -1; - } - if (a->preview_render_size > b->preview_render_size) { - return 1; - } - - if (a->rectx < b->rectx) { - return -1; - } - if (a->rectx > b->rectx) { - return 1; - } - - if (a->recty < b->recty) { - return -1; - } - if (a->recty > b->recty) { - return 1; - } - - if (a->bmain < b->bmain) { - return -1; - } - if (a->bmain > b->bmain) { - return 1; - } - - if (a->scene < b->scene) { - return -1; - } - if (a->scene > b->scene) { - return 1; - } - - if (a->motion_blur_shutter < b->motion_blur_shutter) { - return -1; - } - if (a->motion_blur_shutter > b->motion_blur_shutter) { - return 1; - } - - if (a->motion_blur_samples < b->motion_blur_samples) { - return -1; - } - if (a->motion_blur_samples > b->motion_blur_samples) { - return 1; - } - - return 0; + return ((a->preview_render_size != b->preview_render_size) || + (a->rectx != b->rectx) || + (a->recty != b->recty) || + (a->bmain != b->bmain) || + (a->scene != b->scene) || + (a->motion_blur_shutter != b->motion_blur_shutter) || + (a->motion_blur_samples != b->motion_blur_samples)); } static unsigned int seq_hash_render_data(const SeqRenderData *a) @@ -148,33 +105,15 @@ static unsigned int seqcache_hashhash(const void *key_) return rval; } -static int seqcache_hashcmp(const void *a_, const void *b_) +static bool seqcache_hashcmp(const void *a_, const void *b_) { const SeqCacheKey *a = (SeqCacheKey *) a_; const SeqCacheKey *b = (SeqCacheKey *) b_; - if (a->seq < b->seq) { - return -1; - } - if (a->seq > b->seq) { - return 1; - } - - if (a->cfra < b->cfra) { - return -1; - } - if (a->cfra > b->cfra) { - return 1; - } - - if (a->type < b->type) { - return -1; - } - if (a->type > b->type) { - return 1; - } - - return seq_cmp_render_data(&a->context, &b->context); + return ((a->seq != b->seq) || + (a->cfra != b->cfra) || + (a->type != b->type) || + seq_cmp_render_data(&a->context, &b->context)); } void BKE_sequencer_cache_destruct(void) diff --git a/source/blender/blenkernel/intern/treehash.c b/source/blender/blenkernel/intern/treehash.c index a65bd28da97..866502c4ae1 100644 --- a/source/blender/blenkernel/intern/treehash.c +++ b/source/blender/blenkernel/intern/treehash.c @@ -91,7 +91,7 @@ static unsigned int tse_hash(const void *ptr) return hash.u_int; } -static int tse_cmp(const void *a, const void *b) +static bool tse_cmp(const void *a, const void *b) { const TreeStoreElem *tse_a = a; const TreeStoreElem *tse_b = b; |