diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:41:43 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:57:34 +0200 |
commit | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch) | |
tree | 198d4ff7665d89307f6ca2469fa38620a9eb1672 /core/message_queue.cpp | |
parent | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff) | |
download | redot-engine-0ee0fa42e6639b6fa474b7cf6afc6b1a78142185.tar.gz |
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/message_queue.cpp')
-rw-r--r-- | core/message_queue.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 36914de0ba..8c71f760b2 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -50,8 +50,9 @@ Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, VARIANT int argc = 0; for (int i = 0; i < VARIANT_ARG_MAX; i++) { - if (argptr[i]->get_type() == Variant::NIL) + if (argptr[i]->get_type() == Variant::NIL) { break; + } argc++; } @@ -65,8 +66,9 @@ Error MessageQueue::push_set(ObjectID p_id, const StringName &p_prop, const Vari if ((buffer_end + room_needed) >= buffer_size) { String type; - if (ObjectDB::get_instance(p_id)) + if (ObjectDB::get_instance(p_id)) { type = ObjectDB::get_instance(p_id)->get_class(); + } print_line("Failed set: " + type + ":" + p_prop + " target ID: " + itos(p_id)); statistics(); ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "Message queue out of memory. Try increasing 'memory/limits/message_queue/max_size_kb' in project settings."); @@ -138,8 +140,9 @@ Error MessageQueue::push_callable(const Callable &p_callable, const Variant **p_ msg->args = p_argcount; msg->callable = p_callable; msg->type = TYPE_CALL; - if (p_show_error) + if (p_show_error) { msg->type |= FLAG_SHOW_ERROR; + } buffer_end += sizeof(Message); @@ -167,23 +170,26 @@ void MessageQueue::statistics() { if (target != nullptr) { switch (message->type & FLAG_MASK) { case TYPE_CALL: { - if (!call_count.has(message->callable)) + if (!call_count.has(message->callable)) { call_count[message->callable] = 0; + } call_count[message->callable]++; } break; case TYPE_NOTIFICATION: { - if (!notify_count.has(message->notification)) + if (!notify_count.has(message->notification)) { notify_count[message->notification] = 0; + } notify_count[message->notification]++; } break; case TYPE_SET: { StringName t = message->callable.get_method(); - if (!set_count.has(t)) + if (!set_count.has(t)) { set_count[t] = 0; + } set_count[t]++; @@ -198,8 +204,9 @@ void MessageQueue::statistics() { } read_pos += sizeof(Message); - if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) + if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) { read_pos += sizeof(Variant) * message->args; + } } print_line("TOTAL BYTES: " + itos(buffer_end)); @@ -261,8 +268,9 @@ void MessageQueue::flush() { Message *message = (Message *)&buffer[read_pos]; uint32_t advance = sizeof(Message); - if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) + if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) { advance += sizeof(Variant) * message->args; + } //pre-advance so this function is reentrant read_pos += advance; @@ -334,14 +342,16 @@ MessageQueue::~MessageQueue() { Variant *args = (Variant *)(message + 1); int argc = message->args; if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) { - for (int i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { args[i].~Variant(); + } } message->~Message(); read_pos += sizeof(Message); - if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) + if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) { read_pos += sizeof(Variant) * message->args; + } } singleton = nullptr; |