> On 13 Dec 2023, at 22:53, Dan Fandrich via curl-library > <[email protected]> wrote: > > On Wed, Dec 13, 2023 at 09:49:07PM +0000, Dmitry Karpov via curl-library > wrote: >> I propose to add a simple check for the cookie file name length and call >> fopen() only if it is greater than zero like: > > Sounds reasonable. > >> if(data) { >> FILE *fp = NULL; >> - if(file) { >> + if(file && strlen(file) > 0) { >> if(!strcmp(file, "-")) > > This forces a traversal of the entire string, which isn't necessary. This > would > be much faster: > > if(file && *file) {
Not necessarily, most compilers will optimize if(strlen(file)>0) into the equivalent of if(*file) even at -O0 optimization level (even GCC 4.1 does that according to godbolt.org). It might still be worth doing though for more arcane compilers on platforms that curl build on. > Are you able to turn this into a PR? +1 -- Daniel Gustafsson -- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html
