[notmuch] [PATCH] Solaris doesn't have 'struct dirent::d_type'

Tomas Carnecky tom at dbservice.com
Mon Dec 21 13:37:41 PST 2009

On 12/20/09 7:02 PM, James Westby wrote:
> From: Tomas Carnecky<tom at dbservice.com>
> Use stat(2) instead.
> Signed-off-by: Tomas Carnecky<tom at dbservice.com>
> Signed-off-by: James Westby<jw+debian at jameswestby.net>
> ---
>    The original patch duplicated asprintf and stat calls, rearraging
>    the code means we don't need to.
>    I have a concern about the duplicated stats in is_maildir, but they
>    are not so easy to save. I ran a quick timing test (3931 files), dropping
>    caches before each set:
>      master:
>        real  2m3.545s
>        real  1m34.571s
>        real  1m36.005s
>      original patch:
>        real  2m18.114s
>        real  1m34.843s
>        real  1m36.317s
>      revised patch:
>        real  2m5.890s
>        real  1m36.387s
>        real  1m36.453s
>    This shoes there is little impact of the code, but given that it is
>    around one percent we may want to make it conditional on platform
>    and save the extra stat calls.

If performance regression is an issue, something like this could be used 
to keep the current code paths in linux and stat() on other platforms:

static bool
is_dir(const char *path, struct dirent *dirent)
#if defined(__sun__)
	... sprintf, stat etc
	(void) path;
	return dirent->d_type == DT_DIR;


More information about the notmuch mailing list