From: Michael Meyer Date: Thu, 31 Dec 2020 03:42:48 +0000 (-0500) Subject: Refactor bones search loop X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ae78183464970ae754fcce0fe42053a724b2015;p=nethack Refactor bones search loop Using a for loop instead of an if and a do/while makes the code much more clear and concise, so that it's easier to understand what the function does at a glance. The actual approach to iterating through the current level's bones files and searching for a match is more or less unchanged. --- diff --git a/src/bones.c b/src/bones.c index e0b81ed3d..d497343f4 100644 --- a/src/bones.c +++ b/src/bones.c @@ -671,12 +671,11 @@ const char *name; Strcat(buf, "-"); len = strlen(buf); - if ((bp = g.level.bonesinfo)) { - do { - if (!strncmp(bp->who, buf, len)) - return TRUE; - } while ((bp = bp->next) != (struct cemetery *) 0); + for (bp = g.level.bonesinfo; bp; bp = bp->next) { + if (!strncmp(bp->who, buf, len)) + return TRUE; } + return FALSE; }