From 37386f112bafa9c4e94c342f6d5f04392a5623f7 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Wed, 3 Oct 2018 13:40:37 -0400 Subject: [PATCH] Remove redundant "== true" code If it can be compared to a boolean, it can be evaluated as one in-place. --- core/bind/core_bind.cpp | 2 +- core/dvector.h | 2 +- core/io/multiplayer_api.cpp | 2 +- core/variant.cpp | 2 +- drivers/wasapi/audio_driver_wasapi.cpp | 2 +- editor/plugins/spatial_editor_plugin.cpp | 2 +- modules/csg/csg.cpp | 2 +- modules/mono/csharp_script.cpp | 4 ++-- modules/visual_script/visual_script_editor.cpp | 4 ++-- .../visual_script_property_selector.cpp | 4 ++-- platform/android/godot_android.cpp | 2 +- platform/android/java_glue.cpp | 2 +- platform/haiku/haiku_direct_window.cpp | 2 +- platform/server/os_server.cpp | 2 +- platform/uwp/os_uwp.cpp | 2 +- platform/windows/os_windows.cpp | 2 +- platform/x11/os_x11.cpp | 2 +- scene/gui/control.cpp | 12 ++++++------ servers/physics_2d/step_2d_sw.cpp | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 57654e96dc7..02b8c71465b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2487,7 +2487,7 @@ _Thread::~_Thread() { if (active) { ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running..."); } - ERR_FAIL_COND(active == true); + ERR_FAIL_COND(active); } ///////////////////////////////////// diff --git a/core/dvector.h b/core/dvector.h index 0d0848a19a2..f6e311f04ff 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -149,7 +149,7 @@ class PoolVector { } } - if (old_alloc->refcount.unref() == true) { + if (old_alloc->refcount.unref()) { //this should never happen but.. #ifdef DEBUG_ENABLED diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 17b77bc5352..d2351c81499 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -578,7 +578,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p network_peer->set_target_peer(E->get()); // To this one specifically. - if (F->get() == true) { + if (F->get()) { // This one confirmed path, so use id. encode_uint32(psc->id, &(packet_cache.write[1])); network_peer->put_packet(packet_cache.ptr(), ofs); diff --git a/core/variant.cpp b/core/variant.cpp index 7d75c2243b1..edbe66ba31a 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -858,7 +858,7 @@ bool Variant::is_one() const { // atomic types case BOOL: { - return _data._bool == true; + return _data._bool; } break; case INT: { diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 3d4979175b9..566940b8722 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -808,7 +808,7 @@ Error AudioDriverWASAPI::capture_start() { Error AudioDriverWASAPI::capture_stop() { - if (audio_input.active == true) { + if (audio_input.active) { audio_input.audio_client->Stop(); audio_input.active = false; diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 114610c562a..76928b10875 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2124,7 +2124,7 @@ void SpatialEditorViewport::_notification(int p_what) { _update_freelook(delta); Node *scene_root = editor->get_scene_tree_dock()->get_editor_data()->get_edited_scene_root(); - if (previewing_cinema == true && scene_root != NULL) { + if (previewing_cinema && scene_root != NULL) { Camera *cam = scene_root->get_viewport()->get_camera(); if (cam != NULL && cam != previewing) { //then switch the viewport's camera to the scene's viewport camera diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index f0103bb71d3..88f3c0338a0 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -805,7 +805,7 @@ void CSGBrushOperation::_merge_poly(MeshMerge &mesh, int p_face_idx, const Build //process points that were not processed for (int i = 0; i < edge_process.size(); i++) { - if (edge_process[i] == true) + if (edge_process[i]) continue; //already processed int intersect_poly = -1; diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 91fd4822357..9392f2eaff1 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1194,7 +1194,7 @@ bool CSharpInstance::set(const StringName &p_name, const Variant &p_value) { MonoObject *ret = method->invoke(mono_object, args); - if (ret && GDMonoMarshal::unbox(ret) == true) + if (ret && GDMonoMarshal::unbox(ret)) return true; break; @@ -1459,7 +1459,7 @@ MonoObject *CSharpInstance::_internal_new_managed() { void CSharpInstance::mono_object_disposed(MonoObject *p_obj) { #ifdef DEBUG_ENABLED - CRASH_COND(base_ref == true); + CRASH_COND(base_ref); CRASH_COND(gchandle.is_null()); #endif CSharpLanguage::get_singleton()->release_script_gchandle(p_obj, gchandle); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 79f71535ad4..5408373ddfd 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2639,7 +2639,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri } undo_redo->create_action(TTR("Add Node")); undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode_new, ofs); - if (vnode_old.is_valid() && p_connecting == true) { + if (vnode_old.is_valid() && p_connecting) { connect_seq(vnode_old, vnode_new, new_id); connect_data(vnode_old, vnode_new, new_id); } @@ -2806,7 +2806,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri } } Ref vnode_old = script->get_node(edited_func, port_action_node); - if (vnode_old.is_valid() && p_connecting == true) { + if (vnode_old.is_valid() && p_connecting) { connect_seq(vnode_old, vnode, port_action_new_node); connect_data(vnode_old, vnode, port_action_new_node); } diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index cd29df9855c..8a395470985 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -228,7 +228,7 @@ void VisualScriptPropertySelector::_update_search() { } } - if (seq_connect == true && visual_script_generic == false) { + if (seq_connect && visual_script_generic == false) { String text = search_box->get_text(); create_visualscript_item(String("VisualScriptCondition"), root, text, String("Condition")); create_visualscript_item(String("VisualScriptSwitch"), root, text, String("Switch")); @@ -392,7 +392,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt break; } } - if (is_filter == true) { + if (is_filter) { continue; } diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 54692dc8314..c46c6f7804b 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -408,7 +408,7 @@ static void engine_draw_frame(struct engine *engine) { // Just fill the screen with a color. //glClearColor(0,1,0,1); //glClear(GL_COLOR_BUFFER_BIT); - if (engine->os && engine->os->main_loop_iterate() == true) { + if (engine->os && engine->os->main_loop_iterate()) { engine->requested_quit = true; return; //should exit instead diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index c3be3a3f11e..ad8f21785d5 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -974,7 +974,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job os_android->process_gyroscope(gyroscope); - if (os_android->main_loop_iterate() == true) { + if (os_android->main_loop_iterate()) { jclass cls = env->FindClass("org/godotengine/godot/Godot"); jmethodID _finish = env->GetMethodID(cls, "forceQuit", "()V"); diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 150e90be651..6b64082250a 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -86,7 +86,7 @@ void HaikuDirectWindow::DirectConnected(direct_buffer_info *info) { void HaikuDirectWindow::MessageReceived(BMessage *message) { switch (message->what) { case REDRAW_MSG: - if (Main::iteration() == true) { + if (Main::iteration()) { view->EnableDirectMode(false); Quit(); } diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 1069d6bbed2..6a7038e9466 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -221,7 +221,7 @@ void OS_Server::run() { while (!force_quit) { - if (Main::iteration() == true) + if (Main::iteration()) break; }; diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index f489c0894f9..64103785933 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -864,7 +864,7 @@ void OSUWP::run() { CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); if (managed_object->alert_close_handle) continue; process_events(); // get rid of pending events - if (Main::iteration() == true) + if (Main::iteration()) break; }; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index e8c209c0fcd..a2dddf172f8 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2737,7 +2737,7 @@ void OS_Windows::run() { while (!force_quit) { process_events(); // get rid of pending events - if (Main::iteration() == true) + if (Main::iteration()) break; }; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5be0b9304a2..e20c1d0e1e9 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -2814,7 +2814,7 @@ void OS_X11::run() { #ifdef JOYDEV_ENABLED joypad->process_joypads(); #endif - if (Main::iteration() == true) + if (Main::iteration()) break; }; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index b90a4c17f46..effcd0abeec 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1079,7 +1079,7 @@ bool Control::has_constant_override(const StringName &p_name) const { bool Control::has_icon(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == "") { - if (has_icon_override(p_name) == true) + if (has_icon_override(p_name)) return true; } @@ -1113,7 +1113,7 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const bool Control::has_shader(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == "") { - if (has_shader_override(p_name) == true) + if (has_shader_override(p_name)) return true; } @@ -1146,7 +1146,7 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == "") { - if (has_stylebox_override(p_name) == true) + if (has_stylebox_override(p_name)) return true; } @@ -1179,7 +1179,7 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c bool Control::has_font(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == "") { - if (has_font_override(p_name) == true) + if (has_font_override(p_name)) return true; } @@ -1213,7 +1213,7 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const bool Control::has_color(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == "") { - if (has_color_override(p_name) == true) + if (has_color_override(p_name)) return true; } @@ -1247,7 +1247,7 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons bool Control::has_constant(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == "") { - if (has_constant_override(p_name) == true) + if (has_constant_override(p_name)) return true; } diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index 0fb7af0c948..e4e1b036237 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -222,7 +222,7 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) { Constraint2DSW *prev_ci = NULL; while (ci) { - if (_setup_island(ci, p_delta) == true) { + if (_setup_island(ci, p_delta)) { //removed the root from the island graph because it is not to be processed