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/blenlib/intern/BLI_ghash.c | |
parent | faaf0c719f3310759bf5f2c9be76f6788a923364 (diff) |
GHash: use bool for comparison (simplify compare)
Diffstat (limited to 'source/blender/blenlib/intern/BLI_ghash.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 74d7fdc88cb..aa17ef393c9 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -683,12 +683,9 @@ unsigned int BLI_ghashutil_ptrhash(const void *key) return (unsigned int)y; } #endif -int BLI_ghashutil_ptrcmp(const void *a, const void *b) +bool BLI_ghashutil_ptrcmp(const void *a, const void *b) { - if (a == b) - return 0; - else - return (a < b) ? -1 : 1; + return (a != b); } unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4]) @@ -704,9 +701,9 @@ unsigned int BLI_ghashutil_uinthash_v4(const unsigned int key[4]) return hash; } -int BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b) +bool BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b) { - return memcmp(a, b, sizeof(unsigned int[4])); + return (memcmp(a, b, sizeof(unsigned int[4])) != 0); } unsigned int BLI_ghashutil_uinthash(unsigned int key) @@ -735,12 +732,9 @@ unsigned int BLI_ghashutil_inthash_p(const void *ptr) return (unsigned int)(key & 0xffffffff); } -int BLI_ghashutil_intcmp(const void *a, const void *b) +bool BLI_ghashutil_intcmp(const void *a, const void *b) { - if (a == b) - return 0; - else - return (a < b) ? -1 : 1; + return (a != b); } /** @@ -774,9 +768,9 @@ unsigned int BLI_ghashutil_strhash_p(const void *ptr) return h; } -int BLI_ghashutil_strcmp(const void *a, const void *b) +bool BLI_ghashutil_strcmp(const void *a, const void *b) { - return strcmp(a, b); + return (strcmp(a, b) != 0); } GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second) @@ -794,15 +788,13 @@ unsigned int BLI_ghashutil_pairhash(const void *ptr) return hash ^ BLI_ghashutil_ptrhash(pair->second); } -int BLI_ghashutil_paircmp(const void *a, const void *b) +bool BLI_ghashutil_paircmp(const void *a, const void *b) { const GHashPair *A = a; const GHashPair *B = b; - int cmp = BLI_ghashutil_ptrcmp(A->first, B->first); - if (cmp == 0) - return BLI_ghashutil_ptrcmp(A->second, B->second); - return cmp; + return (BLI_ghashutil_ptrcmp(A->first, B->first) || + BLI_ghashutil_ptrcmp(A->second, B->second)); } void BLI_ghashutil_pairfree(void *ptr) |