From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: A micro-optimisation for walkdir() |
Date: | 2020-09-04 21:45:10 |
Message-ID: | 20200904214510.uoky67sf3pfz6gln@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2020-09-02 17:51:27 +0200, Juan José Santamaría Flecha wrote:
> Win32 could also benefit from this micro-optimisation if we expanded the
> dirent port to include d_type. Please find attached a patch that does
> so
.
> }
> strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */
> d->ret.d_namlen = strlen(d->ret.d_name);
> + /*
> + * The only identifed types are: directory, regular file or symbolic link.
> + * Errors are treated as a file type that could not be determined.
> + */
> + attrib = GetFileAttributes(d->ret.d_name);
> + if (attrib == INVALID_FILE_ATTRIBUTES)
> + d->ret.d_type = DT_UNKNOWN;
> + else if ((attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
> + d->ret.d_type = DT_DIR;
> + else if ((attrib & FILE_ATTRIBUTE_REPARSE_POINT) != 0)
> + d->ret.d_type = DT_LNK;
> + else
> + d->ret.d_type = DT_REG;
>
> return &d->ret;
> }
Is this really an optimization? The benefit of Thomas' patch is that
that information sometimes already is there. But here you're doing a
separate lookup with GetFileAttributes()?
What am I missing?
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2020-09-04 21:52:54 | Re: A micro-optimisation for walkdir() |
Previous Message | Tom Lane | 2020-09-04 21:41:11 | Re: Questionable ping logic in LogicalRepApplyLoop |