[evince/outline-collapse-all] Add comment about logic of 'first_iteration'



commit 3bd2211170d315a1995670a0c2be8bebdd745819
Author: Nelson Benítez León <nbenitezl gmail com>
Date:   Fri Jun 25 21:52:52 2021 -0400

    Add comment about logic of 'first_iteration'

 shell/ev-sidebar-links.c | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c
index 0081562b..758f82fa 100644
--- a/shell/ev-sidebar-links.c
+++ b/shell/ev-sidebar-links.c
@@ -534,6 +534,11 @@ remove_path_descendants (const gchar *metadata_index, GtkTreePath *path)
                        g_free (ret);
                        ret = g_strdup ("");
                }
+               /* Purpose of 'first_iteration' is so that, just in the first iteration, we don't
+                * free 'haystack'. In first iteration, 'haystack' references const char data, while
+                * subsequent iterations will reference allocated char data. This optimization is to
+                * avoid an initial g_strdup() of the passed in 'const gchar *metadata_index' string,
+                * which can be large in documents with big outlines. */
                if (!first_iteration)
                        g_free (haystack);
                else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]