lkml.org 
[lkml]   [2012]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 02/13] perf annotate: Parse instruction
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


\
 
 \ /
  Last update: 2012-04-20 12:55    [W:0.068 / U:1.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site