lkml.org 
[lkml]   [2014]   [Oct]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 04/16] perf tools: Add a thread stack for synthesizing call chains
Date
On Thu, 23 Oct 2014 13:45:12 +0300, Adrian Hunter wrote:
> +static void thread_stack__pop(struct thread_stack *ts, u64 ret_addr)
> +{
> + if (!ts->cnt)
> + return;
> +
> + if (ts->stack[ts->cnt - 1].ret_addr == ret_addr) {
> + ts->cnt -= 1;
> + } else {
> + size_t i = ts->cnt - 1;
> +
> + while (i--) {
> + if (ts->stack[i].ret_addr == ret_addr) {
> + ts->cnt = i;
> + return;
> + }
> + }
> + }
> +}

Why not making it a single loop like:

int i;

for (i = ts->cnt - 1; i >= 0; i--) {
if (ts->stack[i].ret_addr == ret_addr) {
ts->cnt = i;
return;
}
}

Thanks,
Namhyung


\
 
 \ /
  Last update: 2014-10-24 08:21    [W:0.292 / U:0.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site