From c1867930c7f5e9588d2fc069ff92979f07503e03 Mon Sep 17 00:00:00 2001 From: Gabriel Wang Date: Mon, 24 Jan 2022 15:42:37 +0000 Subject: [PATCH] simplify args_getNode_hash --- src/dataArgs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/dataArgs.c b/src/dataArgs.c index 32113f334..f6e7519b4 100644 --- a/src/dataArgs.c +++ b/src/dataArgs.c @@ -245,21 +245,20 @@ int32_t args_setArg(Args* self, Arg* arg) { } LinkNode* args_getNode_hash(Args* self, Hash nameHash) { + LinkNode* nodeNow = self->firstNode; - if (NULL == nodeNow) { - return NULL; - } - while (1) { + + while (NULL != nodeNow) { Arg* arg = nodeNow; Hash thisNameHash = arg_getNameHash(arg); if (thisNameHash == nameHash) { return nodeNow; } - if (NULL == content_getNext(nodeNow)) { - return NULL; - } + nodeNow = content_getNext(nodeNow); } + + return NULL; } LinkNode* args_getNode(Args* self, char* name) {