Re: refactoring basebackup.c (zstd workers) - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: refactoring basebackup.c (zstd workers)
Date
Msg-id 20220329000727.GV28503@telsasoft.com
Whole thread Raw
In response to Re: refactoring basebackup.c (zstd workers)  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Mon, Mar 28, 2022 at 05:39:31PM -0400, Robert Haas wrote:
> On Mon, Mar 28, 2022 at 4:53 PM Justin Pryzby <pryzby@telsasoft.com> wrote:
> > I suggest to write it differently, as in 0002.
> 
> That doesn't seem better to me. What's the argument for it?

I find this much easier to understand:

                /* If we got an error or have reached the end of the string, stop. */
                                                                                                          
 
-               if (result->parse_error != NULL || *kwend == '\0' || *vend == '\0')
                                                                                                          
 
+               if (result->parse_error != NULL)
                                                                                                          
 
+                       break;
                                                                                                          
 
+               if (*kwend == '\0')
                                                                                                          
 
+                       break;
                                                                                                          
 
+               if (vend != NULL && *vend == '\0')
                                                                                                          
 
                        break;
                                                                                                          
 

than

                /* If we got an error or have reached the end of the string, stop. */
-               if (result->parse_error != NULL || *kwend == '\0' || *vend == '\0')
+               if (result->parse_error != NULL ||
+                       (vend == NULL ? *kwend == '\0' : *vend == '\0'))

Also, why wouldn't *kwend be checked in any case ?



pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: [PATCH] Add extra statistics to explain for Nested Loop
Next
From: Tom Lane
Date:
Subject: Re: refactoring basebackup.c (zstd workers)