From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- core/reference.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'core/reference.cpp') diff --git a/core/reference.cpp b/core/reference.cpp index 57b72dcaad..cc8a9854fb 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -33,22 +33,18 @@ #include "core/script_language.h" bool Reference::init_ref() { - if (reference()) { - if (!is_referenced() && refcount_init.unref()) { unreference(); // first referencing is already 1, so compensate for the ref above } return true; } else { - return false; } } void Reference::_bind_methods() { - ClassDB::bind_method(D_METHOD("init_ref"), &Reference::init_ref); ClassDB::bind_method(D_METHOD("reference"), &Reference::reference); ClassDB::bind_method(D_METHOD("unreference"), &Reference::unreference); @@ -59,7 +55,6 @@ int Reference::reference_get_count() const { } bool Reference::reference() { - uint32_t rc_val = refcount.refval(); bool success = rc_val != 0; @@ -80,7 +75,6 @@ bool Reference::reference() { } bool Reference::unreference() { - uint32_t rc_val = refcount.unrefval(); bool die = rc_val == 0; @@ -104,13 +98,11 @@ bool Reference::unreference() { Reference::Reference() : Object(true) { - refcount.init(); refcount_init.init(); } Variant WeakRef::get_ref() const { - if (ref.is_null()) return Variant(); @@ -119,7 +111,6 @@ Variant WeakRef::get_ref() const { return Variant(); Reference *r = cast_to(obj); if (r) { - return REF(r); } @@ -131,11 +122,9 @@ void WeakRef::set_obj(Object *p_object) { } void WeakRef::set_ref(const REF &p_ref) { - ref = p_ref.is_valid() ? p_ref->get_instance_id() : ObjectID(); } void WeakRef::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_ref"), &WeakRef::get_ref); } -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: 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 --- core/reference.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/reference.cpp') diff --git a/core/reference.cpp b/core/reference.cpp index cc8a9854fb..d1dba0d9bf 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -103,12 +103,14 @@ Reference::Reference() : } Variant WeakRef::get_ref() const { - if (ref.is_null()) + if (ref.is_null()) { return Variant(); + } Object *obj = ObjectDB::get_instance(ref); - if (!obj) + if (!obj) { return Variant(); + } Reference *r = cast_to(obj); if (r) { return REF(r); -- cgit v1.2.3