From 486e2a622a3152e4a44f4c6a1d966918d47eb6d4 Mon Sep 17 00:00:00 2001 From: Gokhan Gulbiz Date: Thu, 16 Mar 2023 11:02:52 +0300 Subject: [PATCH] Refactoring to reduce nesting --- src/backend/distributed/utils/attribute.c | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/backend/distributed/utils/attribute.c b/src/backend/distributed/utils/attribute.c index 9aef7b156..55dffffec 100644 --- a/src/backend/distributed/utils/attribute.c +++ b/src/backend/distributed/utils/attribute.c @@ -691,18 +691,20 @@ ExtractTopComment(const char *inputString) int commentEndCharsIndex = 0; - /* If query starts with a comment */ - if (inputString[commentEndCharsIndex] == '/' && - inputString[commentEndCharsIndex + 1] == '*') + /* If query doesn't start with a comment, return NULL */ + if (inputString[commentEndCharsIndex] != '/' || + inputString[commentEndCharsIndex + 1] != '*') { - /* Skip the comment start characters */ - commentEndCharsIndex += commentStartCharsLength; - while (commentEndCharsIndex < inputStringLen && - !(inputString[commentEndCharsIndex] == '*' && - inputString [commentEndCharsIndex + 1] == '/')) - { - commentEndCharsIndex++; - } + return NULL; + } + + /* Skip the comment start characters */ + commentEndCharsIndex += commentStartCharsLength; + while (commentEndCharsIndex < inputStringLen && + !(inputString[commentEndCharsIndex] == '*' && + inputString [commentEndCharsIndex + 1] == '/')) + { + commentEndCharsIndex++; } if (commentEndCharsIndex > commentStartCharsLength)