From d06a8320e5d5117f8a057da16d33443f410a5d9f Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 18 Oct 2022 18:47:44 +0200 Subject: Simplify GDVIRTUAL_CALL calls --- core/io/image_loader.cpp | 6 ++---- core/io/resource_loader.cpp | 31 +++++++++---------------------- core/io/resource_saver.cpp | 14 ++++---------- core/os/main_loop.cpp | 18 ++++++------------ 4 files changed, 21 insertions(+), 48 deletions(-) (limited to 'core') diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 397984a2ab..6c00ca4b67 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -52,10 +52,8 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { Error ImageFormatLoaderExtension::load_image(Ref p_image, Ref p_fileaccess, BitField p_flags, float p_scale) { Error err = ERR_UNAVAILABLE; - if (GDVIRTUAL_CALL(_load_image, p_image, p_fileaccess, p_flags, p_scale, err)) { - return err; - } - return ERR_UNAVAILABLE; + GDVIRTUAL_CALL(_load_image, p_image, p_fileaccess, p_flags, p_scale, err); + return err; } void ImageFormatLoaderExtension::get_recognized_extensions(List *p_extension) const { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 2fb357b520..4e9e8dabb8 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -74,11 +74,8 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_ bool ResourceFormatLoader::handles_type(const String &p_type) const { bool success = false; - if (GDVIRTUAL_CALL(_handles_type, p_type, success)) { - return success; - } - - return false; + GDVIRTUAL_CALL(_handles_type, p_type, success); + return success; } void ResourceFormatLoader::get_classes_used(const String &p_path, HashSet *r_classes) { @@ -98,21 +95,14 @@ void ResourceFormatLoader::get_classes_used(const String &p_path, HashSet *p_extensions) const { @@ -132,7 +122,7 @@ bool ResourceFormatLoader::exists(const String &p_path) const { if (GDVIRTUAL_CALL(_exists, p_path, success)) { return success; } - return FileAccess::exists(p_path); //by default just check file + return FileAccess::exists(p_path); // By default just check file. } void ResourceFormatLoader::get_recognized_extensions(List *p_extensions) const { @@ -181,11 +171,8 @@ Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Hash } int64_t err = OK; - if (GDVIRTUAL_CALL(_rename_dependencies, p_path, deps_dict, err)) { - return (Error)err; - } - - return OK; + GDVIRTUAL_CALL(_rename_dependencies, p_path, deps_dict, err); + return (Error)err; } void ResourceFormatLoader::_bind_methods() { diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 2f863baaac..f55b4c971a 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -43,20 +43,14 @@ ResourceSaverGetResourceIDForPath ResourceSaver::save_get_id_for_path = nullptr; Error ResourceFormatSaver::save(const Ref &p_resource, const String &p_path, uint32_t p_flags) { int64_t res = ERR_METHOD_NOT_FOUND; - if (GDVIRTUAL_CALL(_save, p_resource, p_path, p_flags, res)) { - return (Error)res; - } - - return ERR_METHOD_NOT_FOUND; + GDVIRTUAL_CALL(_save, p_resource, p_path, p_flags, res); + return (Error)res; } bool ResourceFormatSaver::recognize(const Ref &p_resource) const { bool success = false; - if (GDVIRTUAL_CALL(_recognize, p_resource, success)) { - return success; - } - - return false; + GDVIRTUAL_CALL(_recognize, p_resource, success); + return success; } void ResourceFormatSaver::get_recognized_extensions(const Ref &p_resource, List *p_extensions) const { diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index a96e1989f9..c0504a174c 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -65,21 +65,15 @@ void MainLoop::initialize() { } bool MainLoop::physics_process(double p_time) { - bool quit; - if (GDVIRTUAL_CALL(_physics_process, p_time, quit)) { - return quit; - } - - return false; + bool quit = false; + GDVIRTUAL_CALL(_physics_process, p_time, quit); + return quit; } bool MainLoop::process(double p_time) { - bool quit; - if (GDVIRTUAL_CALL(_process, p_time, quit)) { - return quit; - } - - return false; + bool quit = false; + GDVIRTUAL_CALL(_process, p_time, quit); + return quit; } void MainLoop::finalize() { -- cgit v1.2.3