diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-31 11:55:56 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-31 11:55:56 +0100 |
commit | be126d42d44bfc3ca4133ff6c3c12fcfe849f0c2 (patch) | |
tree | d7bcb97c48e7cef1a234ab13ad9eeb9e65afa50b /core | |
parent | 33c7c8020a7c1b4103642ff5124b2b76ecdeea14 (diff) | |
parent | d06a8320e5d5117f8a057da16d33443f410a5d9f (diff) |
Merge pull request #67588 from KoBeWi/if(!GDVIRTUAL_CALL)don't
Simplify GDVIRTUAL_CALL calls
Diffstat (limited to 'core')
-rw-r--r-- | core/io/image_loader.cpp | 6 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 31 | ||||
-rw-r--r-- | core/io/resource_saver.cpp | 14 | ||||
-rw-r--r-- | core/os/main_loop.cpp | 18 |
4 files changed, 21 insertions, 48 deletions
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<Image> p_image, Ref<FileAccess> p_fileaccess, BitField<ImageFormatLoader::LoaderFlags> 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<String> *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<StringName> *r_classes) { @@ -98,21 +95,14 @@ void ResourceFormatLoader::get_classes_used(const String &p_path, HashSet<String String ResourceFormatLoader::get_resource_type(const String &p_path) const { String ret; - - if (GDVIRTUAL_CALL(_get_resource_type, p_path, ret)) { - return ret; - } - - return ""; + GDVIRTUAL_CALL(_get_resource_type, p_path, ret); + return ret; } ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) const { int64_t uid = ResourceUID::INVALID_ID; - if (GDVIRTUAL_CALL(_get_resource_uid, p_path, uid)) { - return uid; - } - - return ResourceUID::INVALID_ID; + GDVIRTUAL_CALL(_get_resource_uid, p_path, uid); + return uid; } void ResourceFormatLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *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<String> *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 6cda840604..710afc614f 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<Resource> &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<Resource> &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<Resource> &p_resource, List<String> *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() { |