[gnome-builder] vim: just make regex static



commit 50750870164554a21c71fd15e6ae5ad8868e593f
Author: Christian Hergert <christian hergert me>
Date:   Mon Jan 19 03:00:32 2015 -0800

    vim: just make regex static
    
    We are always called from the main thread, so we'll just leak the pointer
    process wide.

 src/vim/gb-source-vim.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/vim/gb-source-vim.c b/src/vim/gb-source-vim.c
index 89b78bd..7652632 100644
--- a/src/vim/gb-source-vim.c
+++ b/src/vim/gb-source-vim.c
@@ -4039,11 +4039,14 @@ gb_source_vim_op_set (GbSourceVim *vim,
 static GbSourceVimOperation
 gb_source_vim_parse_operation (const gchar *command_text)
 {
-  GRegex *goto_line_regex = NULL;
+  static GRegex *goto_line_regex = NULL;
   GbSourceVimOperation ret = NULL;
 
   g_return_val_if_fail (command_text, NULL);
 
+  if (!goto_line_regex)
+    goto_line_regex = g_regex_new ("^([0-9]+|\\$)$", 0, 0, NULL);
+
   if (g_str_equal (command_text, "sort"))
     ret = gb_source_vim_op_sort;
   else if (g_str_equal (command_text, "nohl"))
@@ -4058,12 +4061,9 @@ gb_source_vim_parse_operation (const gchar *command_text)
     ret = gb_source_vim_op_search_and_replace;
   else if (g_str_has_prefix (command_text, "s")) /* not ideal */
     ret = gb_source_vim_op_search_and_replace;
-  else if ((goto_line_regex = g_regex_new ("^([0-9]+|\\$)$", 0, 0, NULL)) &&
-           g_regex_match (goto_line_regex, command_text, 0, NULL))
+  else if (g_regex_match (goto_line_regex, command_text, 0, NULL))
     ret = gb_source_vim_op_goto_line;
 
-  g_clear_pointer (&goto_line_regex, g_regex_unref);
-
   return ret;
 }
 


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