Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename empty() to is_empty() #44401

Merged
merged 1 commit into from
Dec 28, 2020

Conversation

madmiraal
Copy link
Contributor

@madmiraal madmiraal commented Dec 15, 2020

Most of Godot's data structures have the method empty() which returns a bool, and is used to determine whether or not the data structure is empty. This can be confused with the action to empty the data structure (for which most of the data structures use clear()). Therefore, to avoid confusion, this method should be renamed is_empty().

This PR renames empty() to is_empty() in all of Godot's data structures.

Part of #16863

Bugsquad edit: This closes godotengine/godot-proposals#1989.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #34193, #42013, #44436, #44472, #44499, #44531, #44605 and #44699.

@akien-mga akien-mga merged commit be509bf into godotengine:master Dec 28, 2020
@akien-mga
Copy link
Member

Thanks!

@madmiraal madmiraal deleted the rename-empty-is_empty branch December 28, 2020 12:25
@bruvzg
Copy link
Member

bruvzg commented Dec 28, 2020

Missing renames:

if (!font_mem_cache.empty()) {

if (p_text.empty()) {

ERR_FAIL_COND_V(span.fonts.empty(), false);

@akien-mga
Copy link
Member

akien-mga commented Dec 28, 2020

Here's the full list of code locations which still refer to .empty(). Not sure why CI didn't fail as some of those should be included in current CI builds.

$ rg "\.empty\(\)" -g'!thirdparty' -g'!*.po' -g'!*.pot'
platform/javascript/http_client_javascript.cpp
81:     ERR_FAIL_COND_V(host.empty(), ERR_UNCONFIGURED);
88:                     username.empty() ? nullptr : username.utf8().get_data(),
89:                     password.empty() ? nullptr : password.utf8().get_data());
135:    return !polled_response_header.empty();
148:    if (polled_response_header.empty())

modules/mono/utils/mono_reg_utils.cpp
191:                                    ERR_BREAK(val.empty());

modules/mono/mono_gd/support/android_support.cpp
137:    if (app_native_lib_dir_cache.empty())

modules/text_server_fb/text_server_fb.cpp
553:    if (p_text.empty()) {
576:    ERR_FAIL_COND_V(span.fonts.empty(), false);

modules/text_server_fb/dynamic_font_fb.cpp
57:                     if (!font_mem_cache.empty()) {

doc/classes/TextEdit.xml
407:                            if !result.empty():

modules/fbx/fbx_parser/FBXAnimation.cpp
169:    if (curves.empty()) {

modules/fbx/fbx_parser/FBXMaterial.cpp
330:    if (Content && !Content->Tokens().empty()) {

modules/fbx/fbx_parser/FBXDocument.cpp
398:            if (tok.empty()) {
467:            if (tok.empty()) {
484:                    if (tok_2.empty()) {
552:    if (!animationStacksResolved.empty() || animationStacks.empty()) {

modules/fbx/fbx_parser/FBXParser.cpp
605:    if (tok.empty()) {
693:    if (tok.empty()) {
770:    if (tok.empty()) {
844:    if (tok.empty()) {
901:    if (tok.empty()) {
964:    if (tok.empty()) {
1030:   if (tok.empty()) {
1089:   if (tok.empty()) {

modules/fbx/fbx_parser/FBXMeshGeometry.cpp
143:    ERR_FAIL_COND_MSG(m_vertices.empty(), "mesh with no vertexes in FBX file, did you mean to delete it?");
144:    ERR_FAIL_COND_MSG(m_face_indices.empty(), "mesh has no faces, was this intended?");

modules/fbx/data/fbx_material.cpp
283:            if (name.empty()) {

platform/javascript/display_server_javascript.cpp
96:     if (target_id.empty() || target_id == String::utf8(display->canvas_id)) {

platform/javascript/api/javascript_tools_editor_plugin.cpp
111:    while (!cur.empty()) {

editor/debugger/editor_visual_profiler.cpp
669:    if (frame_metrics.empty()) {

scene/animation/animation_player.cpp
785:                    if (!backwards && cd.pos <= len && next_pos == len /*&& playback.blend.empty()*/) {
791:                    if (backwards && cd.pos >= 0 && next_pos == 0 /*&& playback.blend.empty()*/) {

I didn't check but the .empty() in the FBX module might be a different method specific to that module.

akien-mga added a commit to akien-mga/godot that referenced this pull request Dec 29, 2020
Those were missed in godotengine#44401 or added by later PRs.
@madmiraal
Copy link
Contributor Author

madmiraal commented Dec 29, 2020

the .empty() in the FBX module might be a different method specific to that module.

These are from the modified Assimp library, which uses the C++ standard library container classes including std::map and std::vector that use empty().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename "empty" function to "is_empty" on Array and Dictionary in GDScript
4 participants