From: Russ Combs (rucombs) Date: Wed, 13 Jan 2016 21:23:15 +0000 (-0500) Subject: Merge pull request #205 in SNORT/snort3 from ~JOCORNET/snort3:profiler_depth_fix... X-Git-Tag: 3.0.0-233~663 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11e5ff85dcc13cf3b7433a9bd5f008b5ce2221ac;p=thirdparty%2Fsnort3.git Merge pull request #205 in SNORT/snort3 from ~JOCORNET/snort3:profiler_depth_fix to master Squashed commit of the following: commit 51304d097ff6a9c154818b12b651e923a3420485 Author: Joel Cornett Date: Tue Jan 12 13:44:58 2016 -0500 initial --- diff --git a/src/profiler/profiler_printer.h b/src/profiler/profiler_printer.h index 82c3d9854..64e1b232a 100644 --- a/src/profiler/profiler_printer.h +++ b/src/profiler/profiler_printer.h @@ -93,12 +93,21 @@ public: LogMessage("%s", ss.str().c_str()); - print_children(root, root, 0, count, max_depth); + print_recursive(root, root, 1, count, max_depth); print_row(root, root, 0, 0); } + void print_recursive(const Entry& root, Entry& cur, int layer, unsigned count, + int max_depth) + { + if ( max_depth >= 0 && max_depth < layer ) + return; + + print_children(root, cur, layer, count, max_depth); + } + void print_children(const Entry& root, Entry& cur, int layer, unsigned count, - int max_depth = -1) + int max_depth) { auto& entries = cur.children; @@ -112,12 +121,8 @@ public: { auto& entry = entries[i]; - print_row(root, entry, layer + 1, i + 1); - - if ( max_depth < 0 ) - print_children(root, entry, layer + 1, count, max_depth); - else if ( max_depth > 0 ) - print_children(root, entry, layer + 1, count, max_depth - 1); + print_row(root, entry, layer, i + 1); + print_recursive(root, entry, layer + 1, count, max_depth); } }