]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #205 in SNORT/snort3 from ~JOCORNET/snort3:profiler_depth_fix...
authorRuss Combs (rucombs) <rucombs@cisco.com>
Wed, 13 Jan 2016 21:23:15 +0000 (16:23 -0500)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Wed, 13 Jan 2016 21:23:15 +0000 (16:23 -0500)
Squashed commit of the following:

commit 51304d097ff6a9c154818b12b651e923a3420485
Author: Joel Cornett <joel.cornett@gmail.com>
Date:   Tue Jan 12 13:44:58 2016 -0500

    initial

src/profiler/profiler_printer.h

index 82c3d9854b3d72616614806bfce54ea1cd1d815a..64e1b232a4c99e337efa7215a523ea8b7028d347 100644 (file)
@@ -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);
         }
     }