summaryrefslogtreecommitdiff
path: root/core/packed_data_container.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:41:43 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 21:57:34 +0200
commit0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch)
tree198d4ff7665d89307f6ca2469fa38620a9eb1672 /core/packed_data_container.cpp
parent07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff)
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'core/packed_data_container.cpp')
-rw-r--r--core/packed_data_container.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index cbaf7e883b..b5aefd6f2c 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -36,8 +36,9 @@
Variant PackedDataContainer::getvar(const Variant &p_key, bool *r_valid) const {
bool err = false;
Variant ret = _key_at_ofs(0, p_key, err);
- if (r_valid)
+ if (r_valid) {
*r_valid = !err;
+ }
return ret;
}
@@ -48,9 +49,9 @@ int PackedDataContainer::size() const {
Variant PackedDataContainer::_iter_init_ofs(const Array &p_iter, uint32_t p_offset) {
Array ref = p_iter;
uint32_t size = _size(p_offset);
- if (size == 0 || ref.size() != 1)
+ if (size == 0 || ref.size() != 1) {
return false;
- else {
+ } else {
ref[0] = 0;
return true;
}
@@ -59,11 +60,13 @@ Variant PackedDataContainer::_iter_init_ofs(const Array &p_iter, uint32_t p_offs
Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offset) {
Array ref = p_iter;
int size = _size(p_offset);
- if (ref.size() != 1)
+ if (ref.size() != 1) {
return false;
+ }
int pos = ref[0];
- if (pos < 0 || pos >= size)
+ if (pos < 0 || pos >= size) {
return false;
+ }
pos += 1;
ref[0] = pos;
return pos != size;
@@ -72,8 +75,9 @@ Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offs
Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_offset) {
int size = _size(p_offset);
int pos = p_iter;
- if (pos < 0 || pos >= size)
+ if (pos < 0 || pos >= size) {
return Variant();
+ }
const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_offset];
@@ -170,16 +174,18 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
uint32_t khash = decode_uint32(r + 8 + i * 12 + 0);
if (khash == hash) {
Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd, err);
- if (err)
+ if (err) {
return Variant();
+ }
if (key == p_key) {
//key matches, return value
return _get_at_ofs(decode_uint32(r + 8 + i * 12 + 8), rd, err);
}
found = true;
} else {
- if (found)
+ if (found) {
break;
+ }
}
}
@@ -375,8 +381,9 @@ void PackedDataContainerRef::_bind_methods() {
Variant PackedDataContainerRef::getvar(const Variant &p_key, bool *r_valid) const {
bool err = false;
Variant ret = from->_key_at_ofs(offset, p_key, err);
- if (r_valid)
+ if (r_valid) {
*r_valid = !err;
+ }
return ret;
}