coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 70x speed-up for seq's common cases


From: Bernhard Voelker
Subject: Re: 70x speed-up for seq's common cases
Date: Fri, 14 Sep 2012 09:56:02 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0

On 09/14/2012 08:54 AM, Jim Meyering wrote:

Real fast now!

> +static bool
> +seq_fast (char const *a, char const *b)
> +{

> [...]

> +      char *buf = xmalloc (N * (n + 1));


Shouldn't we free(buf), too?


> @@ -412,6 +520,33 @@ main (int argc, char **argv)

> [...]

> +  if (format_str == NULL
> +      && all_digits_p (argv[1])
> +      && (n_args == 1 || all_digits_p (argv[2]))
> +      && (n_args < 3 || STREQ ("1", argv[3])))
> +    {
> +      char const *s1 = n_args == 1 ? "1" : argv[1];
> +      char const *s2 = n_args == 1 ? argv[1] : argv[2];
> +      if (seq_fast (s1, s2))
> +        exit (EXIT_SUCCESS);
> +
> +      /* Upon any failure, let the more general code deal with it.  */
> +    }

seq_fast can only return ok.


BTW:
src/seq.c: In function 'all_digits_p':
src/seq.c:440:1: error: function might be candidate for attribute 'pure' if it 
is known to return normally
[-Werror=suggest-attribute=pure]

Therefore:
  -static bool
  +static bool _GL_ATTRIBUTE_PURE
  all_digits_p (char const *s)


Have a nice day,
Berny




reply via email to

[Prev in Thread] Current Thread [Next in Thread]