From 8cbbdedaf4dfec9e320e7e2be58b75d256950df1 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 20 Jul 2020 12:16:20 +0200 Subject: Refactor: Update integer type usage This updates the usage of integer types in code I wrote according to our new style guides. Major changes: * Use signed instead of unsigned integers in many places. * C++ containers in blenlib use `int64_t` for size and indices now (instead of `uint`). * Hash values for C++ containers are 64 bit wide now (instead of 32 bit). I do hope that I broke no builds, but it is quite likely that some compiler reports slightly different errors. Please let me know when there are any errors. If the fix is small, feel free to commit it yourself. I compiled successfully on linux with gcc and on windows. --- source/blender/blenlib/BLI_map_slots.hh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/blenlib/BLI_map_slots.hh') diff --git a/source/blender/blenlib/BLI_map_slots.hh b/source/blender/blenlib/BLI_map_slots.hh index ff3ed34eb9d..b5360795a13 100644 --- a/source/blender/blenlib/BLI_map_slots.hh +++ b/source/blender/blenlib/BLI_map_slots.hh @@ -155,7 +155,7 @@ template class SimpleMapSlot { * Returns the hash of the currently stored key. In this simple map slot implementation, we just * computed the hash here. Other implementations might store the hash in the slot instead. */ - template uint32_t get_hash(const Hash &hash) + template uint64_t get_hash(const Hash &hash) { BLI_assert(this->is_occupied()); return hash(*key_buffer_); @@ -165,7 +165,7 @@ template class SimpleMapSlot { * Move the other slot into this slot and destruct it. We do destruction here, because this way * we can avoid a comparison with the state, since we know the slot is occupied. */ - void relocate_occupied_here(SimpleMapSlot &other, uint32_t UNUSED(hash)) + void relocate_occupied_here(SimpleMapSlot &other, uint64_t UNUSED(hash)) { BLI_assert(!this->is_occupied()); BLI_assert(other.is_occupied()); @@ -181,7 +181,7 @@ template class SimpleMapSlot { * key. The hash can be used by other slot implementations to determine inequality faster. */ template - bool contains(const ForwardKey &key, const IsEqual &is_equal, uint32_t UNUSED(hash)) const + bool contains(const ForwardKey &key, const IsEqual &is_equal, uint64_t UNUSED(hash)) const { if (state_ == Occupied) { return is_equal(key, *key_buffer_); @@ -194,7 +194,7 @@ template class SimpleMapSlot { * constructed by calling the constructor with the given key/value as parameter. */ template - void occupy(ForwardKey &&key, ForwardValue &&value, uint32_t hash) + void occupy(ForwardKey &&key, ForwardValue &&value, uint64_t hash) { BLI_assert(!this->is_occupied()); this->occupy_without_value(std::forward(key), hash); @@ -205,7 +205,7 @@ template class SimpleMapSlot { * Change the state of this slot from empty/removed to occupied, but leave the value * uninitialized. The caller is responsible to construct the value afterwards. */ - template void occupy_without_value(ForwardKey &&key, uint32_t UNUSED(hash)) + template void occupy_without_value(ForwardKey &&key, uint64_t UNUSED(hash)) { BLI_assert(!this->is_occupied()); state_ = Occupied; @@ -292,13 +292,13 @@ template class IntrusiveMapSlot return KeyInfo::is_empty(key_); } - template uint32_t get_hash(const Hash &hash) + template uint64_t get_hash(const Hash &hash) { BLI_assert(this->is_occupied()); return hash(key_); } - void relocate_occupied_here(IntrusiveMapSlot &other, uint32_t UNUSED(hash)) + void relocate_occupied_here(IntrusiveMapSlot &other, uint64_t UNUSED(hash)) { BLI_assert(!this->is_occupied()); BLI_assert(other.is_occupied()); @@ -309,14 +309,14 @@ template class IntrusiveMapSlot } template - bool contains(const ForwardKey &key, const IsEqual &is_equal, uint32_t UNUSED(hash)) const + bool contains(const ForwardKey &key, const IsEqual &is_equal, uint64_t UNUSED(hash)) const { BLI_assert(KeyInfo::is_not_empty_or_removed(key)); return is_equal(key, key_); } template - void occupy(ForwardKey &&key, ForwardValue &&value, uint32_t hash) + void occupy(ForwardKey &&key, ForwardValue &&value, uint64_t hash) { BLI_assert(!this->is_occupied()); BLI_assert(KeyInfo::is_not_empty_or_removed(key)); @@ -324,7 +324,7 @@ template class IntrusiveMapSlot new (&value_buffer_) Value(std::forward(value)); } - template void occupy_without_value(ForwardKey &&key, uint32_t UNUSED(hash)) + template void occupy_without_value(ForwardKey &&key, uint64_t UNUSED(hash)) { BLI_assert(!this->is_occupied()); BLI_assert(KeyInfo::is_not_empty_or_removed(key)); -- cgit v1.2.3