From ea97370f973374f863e4296c2bb872be8b5235a3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 12 Aug 2019 09:48:55 +0200 Subject: Before interpreter. Cleanup build script. Begin writing code analyzer tool to find common mistakes --- src/std/hash_map.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/std') diff --git a/src/std/hash_map.c b/src/std/hash_map.c index bcb43eb..c2e42c1 100644 --- a/src/std/hash_map.c +++ b/src/std/hash_map.c @@ -205,13 +205,12 @@ bool hash_map_get(HashMap *self, BufferView key, void *value) { int hash_map_compare_string(const void *a, const void *b) { const BufferView *lhs; const BufferView *rhs; - int mem_diff; lhs = a; rhs = b; - mem_diff = am_memcmp(lhs->data, rhs->data, MIN(lhs->size, rhs->size)); - if(mem_diff == 0) - return (int)lhs->size - (int)rhs->size; - else - return mem_diff; + + if(lhs->size != rhs->size) + return -1; + + return am_memcmp(lhs->data, rhs->data, MIN(lhs->size, rhs->size)); } -- cgit v1.2.3-70-g09d2