From 818fe73a05dec77dbd98fcfb7c7e2fc25c307a13 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 19 May 2016 14:08:55 -0700 Subject: [PATCH] Remove unnecessary g_strdup_printf. SQL_OPTION_TO_REMOVE is substituted during preprocessing so it can be inlined in the string initialization, no need for heap allocation or runtime composition. --- src/backend/dbi/gnc-backend-dbi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/dbi/gnc-backend-dbi.c b/src/backend/dbi/gnc-backend-dbi.c index e1eeafeede..f075202992 100644 --- a/src/backend/dbi/gnc-backend-dbi.c +++ b/src/backend/dbi/gnc-backend-dbi.c @@ -802,11 +802,11 @@ adjust_sql_options_string (const gchar *str) gchar* regex_str = NULL; gchar* answer = NULL; - regex_str = g_strdup_printf( "(?:,%s$|\\b%s\\b,?)", - SQL_OPTION_TO_REMOVE, SQL_OPTION_TO_REMOVE ); /* Build a regex string that will find the pattern at the beginning, end or * within the string as a whole word, comma separated. */ + regex_str = "(?:," SQL_OPTION_TO_REMOVE "$|\\b" + SQL_OPTION_TO_REMOVE "\\b,?)"; // compile the regular expression and check for errors regex = g_regex_new (regex_str, 0, 0, &err); @@ -822,7 +822,6 @@ adjust_sql_options_string (const gchar *str) { answer = g_strdup (str); } - g_free( regex_str ); g_regex_unref (regex); return answer; }