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

length() over .len #6546

Merged
merged 2 commits into from
Jul 3, 2024
Merged

length() over .len #6546

merged 2 commits into from
Jul 3, 2024

Conversation

Doubleumc
Copy link
Contributor

@Doubleumc Doubleumc commented Jun 24, 2024

About the pull request

Replaces list.len lookup with length(list).

The following replacements are broadly applied:

  • list.len -> length(list) : except where len is being assigned or modified, such as list.len--`, which is a valid use-case
  • list && list.len, !isnull(list) && list.len, list?.len -> LAZYLEN(list) : also the inverted form; LAZYLEN is just a define for length but is used here to more clearly communicate that originally the list was tested for existence
  • if(list.len) list.Cut() -> LAZYCLEARLIST(list) : identical to the define so instead of replacing len with length just used the define

A few one-offs:

  • (list?(list.len):(0)) -> (LAZYLEN(list) || 0) in recipe.dm : resulting value gets assigned to a variable that is used elsewhere, so ensured it returned 0 in the same circumstances
  • if(!list || !list.len) { return FALSE } if(list?.len) { ...-> if(!LAZYLEN(list)) { return FALSE } ... in modify_variables.dm : simplified two branching checks into one
  • !list || list.len == 0 -> !LAZYLEN(list) in teleporter.dm : removed the == test to allow simplifying down to LAZYLEN while ensuring it has the same truthiness

Explain why it's good for the game

length(list) is preferred over list.len since it inherently handles nulls and is allegedly slightly more performant.

Testing Photographs and Procedure

Boots without issue.

Changelog

No player-facing changes.

@github-actions github-actions bot added the Missing Changelog Maintainers always document their changes. label Jun 24, 2024
@harryob harryob added this pull request to the merge queue Jul 3, 2024
Merged via the queue into cmss13-devs:master with commit 72fa385 Jul 3, 2024
27 checks passed
@Doubleumc Doubleumc deleted the length-over-len branch July 3, 2024 19:57
harryob added a commit to ThePiachu/cmss13 that referenced this pull request Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing Changelog Maintainers always document their changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants