Remove unnecessary else branch - Mailing list pgsql-hackers

From Li Japin
Subject Remove unnecessary else branch
Date
Msg-id 887E132F-5321-4572-AE74-1957BE6C6634@hotmail.com
Whole thread Raw
Responses Re: Remove unnecessary else branch
List pgsql-hackers
Hi,

I found in guc-file.l we can omit the else branch in AbsoluteConfigLocation().

diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index c98e220295..9d4b3d7236 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -522,23 +522,21 @@ AbsoluteConfigLocation(const char *location, const char *calling_file)

        if (is_absolute_path(location))
                return pstrdup(location);
+
+       if (calling_file != NULL)
+       {
+               strlcpy(abs_path, calling_file, sizeof(abs_path));
+               get_parent_directory(abs_path);
+               join_path_components(abs_path, abs_path, location);
+               canonicalize_path(abs_path);
+       }
        else
        {
-               if (calling_file != NULL)
-               {
-                       strlcpy(abs_path, calling_file, sizeof(abs_path));
-                       get_parent_directory(abs_path);
-                       join_path_components(abs_path, abs_path, location);
-                       canonicalize_path(abs_path);
-               }
-               else
-               {
-                       AssertState(DataDir);
-                       join_path_components(abs_path, DataDir, location);
-                       canonicalize_path(abs_path);
-               }
-               return pstrdup(abs_path);
+               AssertState(DataDir);
+               join_path_components(abs_path, DataDir, location);
+               canonicalize_path(abs_path);
        }
+       return pstrdup(abs_path);
 }


--
Best regards
Japin Li






pgsql-hackers by date:

Previous
From: gkokolatos@pm.me
Date:
Subject: Re: PATCH: Attempt to make dbsize a bit more consistent
Next
From: Heikki Linnakangas
Date:
Subject: Re: Remove unnecessary else branch