From 6ae78183464970ae754fcce0fe42053a724b2015 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Wed, 30 Dec 2020 22:42:48 -0500 Subject: [PATCH] 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. --- src/bones.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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; }