Re: A micro-optimisation for walkdir()

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: A micro-optimisation for walkdir()
Дата
Msg-id 20200904214510.uoky67sf3pfz6gln@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: A micro-optimisation for walkdir()  (Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>)
Ответы Re: A micro-optimisation for walkdir()
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Questionable ping logic in LogicalRepApplyLoop
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: A micro-optimisation for walkdir()