Em Mon, Jul 01, 2019 at 11:33:20PM -0400, André Goddard Rosa escreveu:
> On Mon, Jul 1, 2019 at 22:28 Arnaldo Carvalho de Melo <a...@kernel.org>
> wrote:
> 
> > From: Arnaldo Carvalho de Melo <a...@redhat.com>
> >
> > Since we're working on moving stuff out of tools/perf/util/ to
> > tools/lib/, take the opportunity to adopt routines from the kernel that
> > are equivalent, so that tools/ code look more like the kernel.

<SNIP>

> > +char *strim(char *s)
> > +{
> > +       size_t size;
> > +       char *end;
> > +
> > +       size = strlen(s);
> > +       if (!size)
> > +               return s;
> > +
> > +       end = s + size - 1;
> > +       while (end >= s && isspace(*end))
> > +               end--;
> > +       *(end + 1) = '\0';
> > +
> > +       return skip_spaces(s);
> > +}
> > --
> > 2.20.1
> 
> 
> Small nit: could call skip_spaces() firstly and save its pointer to return
> later and then remove the trailing spaces. That’ll make strlen() iterate
> over a smaller string.

Hey, this is just  a copy of what is in the kernel sources, so as soon
as this gets improved there we'll grab a copy again can you do that for
the kernel first? :-)

- Arnaldo

Reply via email to