[RFC] dirstate walk speedup

Emanuele Aina em at nerd.ocracy.org
Sun Sep 30 06:30:47 CDT 2007


Bryan O'Sullivan convertì:

> +static inline int mode_to_kind(int mode)
> +{
> +    if (S_ISREG(mode)) return S_IFREG;
> +    if (S_ISDIR(mode)) return S_IFDIR;
> +    if (S_ISLNK(mode)) return S_IFLNK;
> +    if (S_ISBLK(mode)) return S_IFBLK;
> +    if (S_ISCHR(mode)) return S_IFCHR;
> +    if (S_ISFIFO(mode)) return S_IFIFO;
> +    if (S_ISSOCK(mode)) return S_IFSOCK;
> +    return mode;
> +}

Looking in dirent.h it seems that something similar to this could be 
done as ((mode) & 0170000).

> +        switch (d_type) {
> +#ifdef DT_REG
> +        case DT_REG: kind = S_IFREG; break;
> +        case DT_DIR: kind = S_IFDIR; break;
> +        case DT_LNK: kind = S_IFLNK; break;
> +        case DT_BLK: kind = S_IFBLK; break;
> +        case DT_CHR: kind = S_IFCHR; break;
> +        case DT_FIFO: kind = S_IFIFO; break;
> +        case DT_SOCK: kind = S_IFSOCK; break;
> +#endif

Maybe here you could use the DTTOIF(dirtype) macro defined in dirent.h
(don't know how portable it is, though).

-- 
Buongiorno.
Complimenti per l'ottima scelta.




More information about the Mercurial-devel mailing list