[gnome-builder] todo: tell git-grep to avoid long lines



commit 479e64f078047883f93c849d4a518889b390ee90
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 25 16:24:33 2018 -0700

    todo: tell git-grep to avoid long lines
    
    This allows us to ignore long lines while git is processing the directory
    tree in the subprocess. Doing so means we don't pollute our GBytes in the
    UI process with data that will never be displayed to the user. Especially
    when said data is pathological minified JS in a given project.
    
    It is important that we do the --and -e length check *after* the TODO
    check so that grep doesn't have to look at every line length as that is
    quite expensive.

 src/plugins/todo/gbp-todo-model.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/plugins/todo/gbp-todo-model.c b/src/plugins/todo/gbp-todo-model.c
index 24da30b5e..d2a3723bb 100644
--- a/src/plugins/todo/gbp-todo-model.c
+++ b/src/plugins/todo/gbp-todo-model.c
@@ -405,6 +405,20 @@ gbp_todo_model_mine_worker (IdeTask      *task,
       arg = g_strdup_printf ("%s(:| )", keyword);
       ide_subprocess_launcher_push_argv (launcher, "-e");
       ide_subprocess_launcher_push_argv (launcher, arg);
+
+      if (m->use_git_grep)
+        {
+          /* Avoid pathological lines up front before reading them into
+           * the UI process memory space.
+           *
+           * Note that we do this *after* our TODO: match because it causes
+           * grep to have to look at every line up to it. So to do this in
+           * reverse order is incredibly slow.
+           */
+          ide_subprocess_launcher_push_argv (launcher, "--and");
+          ide_subprocess_launcher_push_argv (launcher, "-e");
+          ide_subprocess_launcher_push_argv (launcher, "^.{0,256}$");
+        }
     }
 
   if (g_file_query_file_type (m->file, 0, NULL) != G_FILE_TYPE_DIRECTORY)


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