From: Mathieu Desnoyers Date: Thu, 21 Mar 2013 02:41:42 +0000 (-0400) Subject: tracepoint: move "probe" test outside of loop X-Git-Tag: v2.2.0-rc1~43 X-Git-Url: http://git.lttng.org/?a=commitdiff_plain;h=956c6fab1fd3200697383908040e6c2aab02e5dd;p=lttng-ust.git tracepoint: move "probe" test outside of loop This is a slow-path optimisation. Reported-by: Sahara Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c index d7293dab..62aaf418 100644 --- a/liblttng-ust/tracepoint.c +++ b/liblttng-ust/tracepoint.c @@ -185,11 +185,14 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, debug_print_probes(entry); /* (N -> M), (N > 1, M >= 0) probes */ - for (nr_probes = 0; old[nr_probes].func; nr_probes++) { - if (!probe || - (old[nr_probes].func == probe && - old[nr_probes].data == data)) - nr_del++; + if (probe) { + for (nr_probes = 0; old[nr_probes].func; nr_probes++) { + if (old[nr_probes].func == probe && + old[nr_probes].data == data) + nr_del++; + } + } else { + nr_del = nr_probes; } if (nr_probes - nr_del == 0) { @@ -206,8 +209,7 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, if (new == NULL) return ERR_PTR(-ENOMEM); for (i = 0; old[i].func; i++) - if (probe && - (old[i].func != probe || old[i].data != data)) + if (old[i].func != probe || old[i].data != data) new[j++] = old[i]; new[nr_probes - nr_del].func = NULL; entry->refcount = nr_probes - nr_del;