Skip to content

Commit

Permalink
Merge pull request #87688 from AThousandShips/what_is_this
Browse files Browse the repository at this point in the history
Remove unnecessary `this->` expressions
  • Loading branch information
akien-mga committed Jan 29, 2024
2 parents e59e58a + 15369fd commit fa48a51
Show file tree
Hide file tree
Showing 39 changed files with 160 additions and 160 deletions.
16 changes: 8 additions & 8 deletions core/math/convex_hull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,31 +344,31 @@ class ConvexHullInternal {
Rational128(int64_t p_value) {
if (p_value > 0) {
sign = 1;
this->numerator = p_value;
numerator = p_value;
} else if (p_value < 0) {
sign = -1;
this->numerator = -p_value;
numerator = -p_value;
} else {
sign = 0;
this->numerator = (uint64_t)0;
numerator = (uint64_t)0;
}
this->denominator = (uint64_t)1;
denominator = (uint64_t)1;
is_int_64 = true;
}

Rational128(const Int128 &p_numerator, const Int128 &p_denominator) {
sign = p_numerator.get_sign();
if (sign >= 0) {
this->numerator = p_numerator;
numerator = p_numerator;
} else {
this->numerator = -p_numerator;
numerator = -p_numerator;
}
int32_t dsign = p_denominator.get_sign();
if (dsign >= 0) {
this->denominator = p_denominator;
denominator = p_denominator;
} else {
sign = -sign;
this->denominator = -p_denominator;
denominator = -p_denominator;
}
is_int_64 = false;
}
Expand Down
4 changes: 2 additions & 2 deletions core/math/vector2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Vector2 Vector2::slide(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector2(), "The normal Vector2 " + p_normal.operator String() + "must be normalized.");
#endif
return *this - p_normal * this->dot(p_normal);
return *this - p_normal * dot(p_normal);
}

Vector2 Vector2::bounce(const Vector2 &p_normal) const {
Expand All @@ -175,7 +175,7 @@ Vector2 Vector2::reflect(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector2(), "The normal Vector2 " + p_normal.operator String() + "must be normalized.");
#endif
return 2.0f * p_normal * this->dot(p_normal) - *this;
return 2.0f * p_normal * dot(p_normal) - *this;
}

bool Vector2::is_equal_approx(const Vector2 &p_v) const {
Expand Down
2 changes: 1 addition & 1 deletion core/math/vector3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Vector3 Vector3::octahedron_decode(const Vector2 &p_oct) {

Vector2 Vector3::octahedron_tangent_encode(const float sign) const {
const float bias = 1.0f / 32767.0f;
Vector2 res = this->octahedron_encode();
Vector2 res = octahedron_encode();
res.y = MAX(res.y, bias);
res.y = res.y * 0.5f + 0.5f;
res.y = sign >= 0.0f ? res.y : 1 - res.y;
Expand Down
4 changes: 2 additions & 2 deletions core/math/vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ Vector3 Vector3::slide(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector3(), "The normal Vector3 " + p_normal.operator String() + " must be normalized.");
#endif
return *this - p_normal * this->dot(p_normal);
return *this - p_normal * dot(p_normal);
}

Vector3 Vector3::bounce(const Vector3 &p_normal) const {
Expand All @@ -525,7 +525,7 @@ Vector3 Vector3::reflect(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector3(), "The normal Vector3 " + p_normal.operator String() + " must be normalized.");
#endif
return 2.0f * p_normal * this->dot(p_normal) - *this;
return 2.0f * p_normal * dot(p_normal) - *this;
}

#endif // VECTOR3_H
12 changes: 6 additions & 6 deletions core/object/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
#ifdef DEV_ENABLED
// Includes safety checks to ensure that a queue set as a thread singleton override
// is only ever called from the thread it was set for.
#define LOCK_MUTEX \
if (this != MessageQueue::thread_singleton) { \
DEV_ASSERT(!this->is_current_thread_override); \
mutex.lock(); \
} else { \
DEV_ASSERT(this->is_current_thread_override); \
#define LOCK_MUTEX \
if (this != MessageQueue::thread_singleton) { \
DEV_ASSERT(!is_current_thread_override); \
mutex.lock(); \
} else { \
DEV_ASSERT(is_current_thread_override); \
}
#else
#define LOCK_MUTEX \
Expand Down
4 changes: 2 additions & 2 deletions core/string/translation_po.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void TranslationPO::print_translation_map() {
return;
}

file->store_line("NPlural : " + String::num_int64(this->get_plural_forms()));
file->store_line("Plural rule : " + this->get_plural_rule());
file->store_line("NPlural : " + String::num_int64(get_plural_forms()));
file->store_line("Plural rule : " + get_plural_rule());
file->store_line("");

List<StringName> context_l;
Expand Down
28 changes: 14 additions & 14 deletions core/string/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void String::copy_from(const char *p_cstr) {

resize(len + 1); // include 0

char32_t *dst = this->ptrw();
char32_t *dst = ptrw();

for (size_t i = 0; i <= len; i++) {
#if CHAR_MIN == 0
Expand Down Expand Up @@ -339,7 +339,7 @@ void String::copy_from(const char *p_cstr, const int p_clip_to) {

resize(len + 1); // include 0

char32_t *dst = this->ptrw();
char32_t *dst = ptrw();

for (int i = 0; i < len; i++) {
#if CHAR_MIN == 0
Expand Down Expand Up @@ -1043,7 +1043,7 @@ String String::_camelcase_to_underscore() const {
String new_string;
int start_index = 0;

for (int i = 1; i < this->size(); i++) {
for (int i = 1; i < size(); i++) {
bool is_prev_upper = is_ascii_upper_case(cstr[i - 1]);
bool is_prev_lower = is_ascii_lower_case(cstr[i - 1]);
bool is_prev_digit = is_digit(cstr[i - 1]);
Expand All @@ -1053,7 +1053,7 @@ String String::_camelcase_to_underscore() const {
bool is_curr_digit = is_digit(cstr[i]);

bool is_next_lower = false;
if (i + 1 < this->size()) {
if (i + 1 < size()) {
is_next_lower = is_ascii_lower_case(cstr[i + 1]);
}

Expand All @@ -1063,17 +1063,17 @@ String String::_camelcase_to_underscore() const {
const bool cond_d = (is_prev_upper || is_prev_lower) && is_curr_digit; // A2, a2

if (cond_a || cond_b || cond_c || cond_d) {
new_string += this->substr(start_index, i - start_index) + "_";
new_string += substr(start_index, i - start_index) + "_";
start_index = i;
}
}

new_string += this->substr(start_index, this->size() - start_index);
new_string += substr(start_index, size() - start_index);
return new_string.to_lower();
}

String String::capitalize() const {
String aux = this->_camelcase_to_underscore().replace("_", " ").strip_edges();
String aux = _camelcase_to_underscore().replace("_", " ").strip_edges();
String cap;
for (int i = 0; i < aux.get_slice_count(" "); i++) {
String slice = aux.get_slicec(' ', i);
Expand All @@ -1090,19 +1090,19 @@ String String::capitalize() const {
}

String String::to_camel_case() const {
String s = this->to_pascal_case();
String s = to_pascal_case();
if (!s.is_empty()) {
s[0] = _find_lower(s[0]);
}
return s;
}

String String::to_pascal_case() const {
return this->capitalize().replace(" ", "");
return capitalize().replace(" ", "");
}

String String::to_snake_case() const {
return this->_camelcase_to_underscore().replace(" ", "_").strip_edges();
return _camelcase_to_underscore().replace(" ", "_").strip_edges();
}

String String::get_with_code_lines() const {
Expand Down Expand Up @@ -1185,7 +1185,7 @@ String String::get_slicec(char32_t p_splitter, int p_slice) const {
return String();
}

const char32_t *c = this->ptr();
const char32_t *c = ptr();
int i = 0;
int prev = 0;
int count = 0;
Expand Down Expand Up @@ -3516,7 +3516,7 @@ bool String::matchn(const String &p_wildcard) const {
}

String String::format(const Variant &values, const String &placeholder) const {
String new_string = String(this->ptr());
String new_string = String(ptr());

if (values.get_type() == Variant::ARRAY) {
Array values_arr = values;
Expand Down Expand Up @@ -4467,7 +4467,7 @@ bool String::is_valid_float() const {

String String::path_to_file(const String &p_path) const {
// Don't get base dir for src, this is expected to be a dir already.
String src = this->replace("\\", "/");
String src = replace("\\", "/");
String dst = p_path.replace("\\", "/").get_base_dir();
String rel = src.path_to(dst);
if (rel == dst) { // failed
Expand All @@ -4478,7 +4478,7 @@ String String::path_to_file(const String &p_path) const {
}

String String::path_to(const String &p_path) const {
String src = this->replace("\\", "/");
String src = replace("\\", "/");
String dst = p_path.replace("\\", "/");
if (!src.ends_with("/")) {
src += "/";
Expand Down
2 changes: 1 addition & 1 deletion core/variant/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void Dictionary::clear() {
void Dictionary::merge(const Dictionary &p_dictionary, bool p_overwrite) {
for (const KeyValue<Variant, Variant> &E : p_dictionary._p->variant_map) {
if (p_overwrite || !has(E.key)) {
this->operator[](E.key) = E.value;
operator[](E.key) = E.value;
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions core/variant/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,53 +1246,53 @@ void Variant::zero() {
case NIL:
break;
case BOOL:
this->_data._bool = false;
_data._bool = false;
break;
case INT:
this->_data._int = 0;
_data._int = 0;
break;
case FLOAT:
this->_data._float = 0;
_data._float = 0;
break;

case VECTOR2:
*reinterpret_cast<Vector2 *>(this->_data._mem) = Vector2();
*reinterpret_cast<Vector2 *>(_data._mem) = Vector2();
break;
case VECTOR2I:
*reinterpret_cast<Vector2i *>(this->_data._mem) = Vector2i();
*reinterpret_cast<Vector2i *>(_data._mem) = Vector2i();
break;
case RECT2:
*reinterpret_cast<Rect2 *>(this->_data._mem) = Rect2();
*reinterpret_cast<Rect2 *>(_data._mem) = Rect2();
break;
case RECT2I:
*reinterpret_cast<Rect2i *>(this->_data._mem) = Rect2i();
*reinterpret_cast<Rect2i *>(_data._mem) = Rect2i();
break;
case VECTOR3:
*reinterpret_cast<Vector3 *>(this->_data._mem) = Vector3();
*reinterpret_cast<Vector3 *>(_data._mem) = Vector3();
break;
case VECTOR3I:
*reinterpret_cast<Vector3i *>(this->_data._mem) = Vector3i();
*reinterpret_cast<Vector3i *>(_data._mem) = Vector3i();
break;
case VECTOR4:
*reinterpret_cast<Vector4 *>(this->_data._mem) = Vector4();
*reinterpret_cast<Vector4 *>(_data._mem) = Vector4();
break;
case VECTOR4I:
*reinterpret_cast<Vector4i *>(this->_data._mem) = Vector4i();
*reinterpret_cast<Vector4i *>(_data._mem) = Vector4i();
break;
case PLANE:
*reinterpret_cast<Plane *>(this->_data._mem) = Plane();
*reinterpret_cast<Plane *>(_data._mem) = Plane();
break;
case QUATERNION:
*reinterpret_cast<Quaternion *>(this->_data._mem) = Quaternion();
*reinterpret_cast<Quaternion *>(_data._mem) = Quaternion();
break;

case COLOR:
*reinterpret_cast<Color *>(this->_data._mem) = Color();
*reinterpret_cast<Color *>(_data._mem) = Color();
break;

default:
Type prev_type = type;
this->clear();
clear();
if (type != prev_type) {
// clear() changes type to NIL, so it needs to be restored.
Callable::CallError ce;
Expand Down
2 changes: 1 addition & 1 deletion core/variant/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Variant {
struct PackedArrayRefBase {
SafeRefCount refcount;
_FORCE_INLINE_ PackedArrayRefBase *reference() {
if (this->refcount.ref()) {
if (refcount.ref()) {
return this;
} else {
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/shader_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ bool ShaderGLES3::_load_from_cache(Version *p_version) {
}

int cache_variant_count = static_cast<int>(f->get_32());
ERR_FAIL_COND_V_MSG(cache_variant_count != this->variant_count, false, "shader cache variant count mismatch, expected " + itos(this->variant_count) + " got " + itos(cache_variant_count)); //should not happen but check
ERR_FAIL_COND_V_MSG(cache_variant_count != variant_count, false, "shader cache variant count mismatch, expected " + itos(variant_count) + " got " + itos(cache_variant_count)); //should not happen but check

LocalVector<OAHashMap<uint64_t, Version::Specialization>> variants;
for (int i = 0; i < cache_variant_count; i++) {
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_audio_buses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void EditorAudioBus::_volume_changed(float p_normalized) {

updating_bus = true;

const float p_db = this->_normalized_volume_to_scaled_db(p_normalized);
const float p_db = _normalized_volume_to_scaled_db(p_normalized);

if (Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL)) {
// Snap the value when holding Ctrl for easier editing.
Expand Down
18 changes: 9 additions & 9 deletions editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,31 +220,31 @@ void EditorHelp::_class_desc_select(const String &p_select) {

if (tag == "method") {
topic = "class_method";
table = &this->method_line;
table = &method_line;
} else if (tag == "constructor") {
topic = "class_method";
table = &this->method_line;
table = &method_line;
} else if (tag == "operator") {
topic = "class_method";
table = &this->method_line;
table = &method_line;
} else if (tag == "member") {
topic = "class_property";
table = &this->property_line;
table = &property_line;
} else if (tag == "enum") {
topic = "class_enum";
table = &this->enum_line;
table = &enum_line;
} else if (tag == "signal") {
topic = "class_signal";
table = &this->signal_line;
table = &signal_line;
} else if (tag == "constant") {
topic = "class_constant";
table = &this->constant_line;
table = &constant_line;
} else if (tag == "annotation") {
topic = "class_annotation";
table = &this->annotation_line;
table = &annotation_line;
} else if (tag == "theme_item") {
topic = "theme_item";
table = &this->theme_property_line;
table = &theme_property_line;
} else {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3789,13 +3789,13 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v
// The "changing" variable must be true for properties that trigger events as typing occurs,
// like "text_changed" signal. E.g. text property of Label, Button, RichTextLabel, etc.
if (p_changing) {
this->changing++;
changing++;
}

_edit_set(p_path, p_value, p_update_all, p_name);

if (p_changing) {
this->changing--;
changing--;
}

if (restart_request_props.has(p_path)) {
Expand Down
Loading

0 comments on commit fa48a51

Please sign in to comment.