list.len -> length(list) : except where len is being assigned or modified, such aslist.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.
About the pull request
Replaces
list.len
lookup withlength(list)
.The following replacements are broadly applied:
list.len
->length(list)
: except wherelen is being assigned or modified, such as
list.len--`, which is a valid use-caselist && list.len
,!isnull(list) && list.len
,list?.len
->LAZYLEN(list)
: also the inverted form;LAZYLEN
is just a define forlength
but is used here to more clearly communicate that originally the list was tested for existenceif(list.len) list.Cut()
->LAZYCLEARLIST(list)
: identical to the define so instead of replacinglen
withlength
just used the defineA few one-offs:
(list?(list.len):(0))
->(LAZYLEN(list) || 0)
inrecipe.dm
: resulting value gets assigned to a variable that is used elsewhere, so ensured it returned 0 in the same circumstancesif(!list || !list.len) { return FALSE } if(list?.len) { ...
->if(!LAZYLEN(list)) { return FALSE } ...
inmodify_variables.dm
: simplified two branching checks into one!list || list.len == 0
->!LAZYLEN(list)
inteleporter.dm
: removed the==
test to allow simplifying down toLAZYLEN
while ensuring it has the same truthinessExplain why it's good for the game
length(list)
is preferred overlist.len
since it inherently handles nulls and is allegedly slightly more performant.Testing Photographs and Procedure
Boots without issue.
Changelog
No player-facing changes.