Re: [PATCH 02/13] perf annotate: Parse instruction

From: Arnaldo Carvalho de Melo
Date: Fri Apr 20 2012 - 06:53:40 EST


Em Thu, Apr 19, 2012 at 05:55:57PM -0600, David Ahern escreveu:
> On 4/19/12 2:33 PM, Arnaldo Carvalho de Melo wrote:
> > dl->offset = offset;
> > dl->line = strdup(line);
> > if (dl->line == NULL)
> > goto out_delete;
> >+
> >+ if (offset != -1) {
> >+ char *name = dl->line, tmp;
> >+
> >+ while (isspace(name[0]))
> >+ ++name;
> >+
> >+ if (name[0] == '\0')
> >+ goto out_delete;
> >+
> >+ dl->operands = name + 1;
> >+
> >+ while (dl->operands[0] != '\0'&&
> >+ !isspace(dl->operands[0]))
> >+ ++dl->operands;
> >+
> >+ tmp = dl->operands[0];
> >+ dl->operands[0] = '\0';
> >+ dl->name = strdup(name);
>
> This strdup seems unnecessary. The parsing seems to be:
>
> dl->line = "\W*name\W*operands"
> dl->name = -^ ^- = dl_operands
>
> so name and operands are 2 different parts of the same buffer.

Yeah, but we still want to do searches in the whole line, sure we could
do that using the name + operands parts, but I got lazy at that point.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/