SF.net SVN: geany: [1156] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Jan 4 11:49:14 UTC 2007


Revision: 1156
          http://svn.sourceforge.net/geany/?rev=1156&view=rev
Author:   ntrel
Date:     2007-01-04 03:49:14 -0800 (Thu, 04 Jan 2007)

Log Message:
-----------
Make build_parse_make_dir() more efficient.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/build.c
    trunk/src/build.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-01-03 16:21:44 UTC (rev 1155)
+++ trunk/ChangeLog	2007-01-04 11:49:14 UTC (rev 1156)
@@ -1,3 +1,9 @@
+2007-01-04  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/build.c, src/build.h:
+   Make build_parse_make_dir() more efficient.
+
+
 2007-01-03  Nick Treleaven  <nick.treleaven at btinternet.com>
 
  * src/sci_cb.c, tagmanager/entry.h, tagmanager/tm_tag.c,

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2007-01-03 16:21:44 UTC (rev 1155)
+++ trunk/src/build.c	2007-01-04 11:49:14 UTC (rev 1156)
@@ -691,13 +691,16 @@
 		{
 			//if (s != G_IO_STATUS_NORMAL && s != G_IO_STATUS_EOF) break;
 			gint color;
+			gchar *tmp;
+
 			color = (GPOINTER_TO_INT(data)) ? COLOR_DARK_RED : COLOR_BLACK;
 			g_strstrip(msg);
 
-			if (strstr(msg, "Entering directory") != NULL) {
+			if (build_parse_make_dir(msg, &tmp))
+			{
 				if (dir != NULL)
 					g_free(dir);
-				build_parse_make_dir(msg, &dir);
+				dir = tmp;
 			}
 
 			if (app->pref_editor_use_indicators)
@@ -729,39 +732,37 @@
 }
 
 
-gboolean build_parse_make_dir(gchar *string, gchar **prefix)
+gboolean build_parse_make_dir(const gchar *string, gchar **prefix)
 {
-	gchar *pos, *input;
+	const gchar *pos;
 
 	*prefix = NULL;
 
-	input = g_strdup(string);
-	if (input == NULL)
+	if (string == NULL)
 		return FALSE;
 
-	if ((pos = strstr(input, "Entering directory")) != NULL)
+	if ((pos = strstr(string, "Entering directory")) != NULL)
 	{
-		gsize len = strlen(input);
+		gsize len;
+		gchar *input;
 
-		//get the start of the path
-		pos = strstr(input, "/");
+		// get the start of the path
+		pos = strstr(string, "/");
 
-		if (pos == NULL) {
-			g_free(input);
+		if (pos == NULL)
 			return FALSE;
-		}
 
-		//kill the ' at the end of the path
-		input[len-1] = '\0';
+		input = g_strdup(pos);
 
-		//duplicate
-		*prefix = g_strdup(pos);
+		// kill the ' at the end of the path
+		len = strlen(input);
+		input[len - 1] = '\0';
+		input = g_realloc(input, len);	// shorten by 1
+		*prefix = input;
 
-		g_free(input);
 		return TRUE;
 	}
 
-	g_free(input);
 	return FALSE;
 }
 

Modified: trunk/src/build.h
===================================================================
--- trunk/src/build.h	2007-01-03 16:21:44 UTC (rev 1155)
+++ trunk/src/build.h	2007-01-04 11:49:14 UTC (rev 1156)
@@ -74,7 +74,7 @@
 
 GPid build_run_cmd(gint idx);
 
-gboolean build_parse_make_dir(gchar *string, gchar **prefix);
+gboolean build_parse_make_dir(const gchar *string, gchar **prefix);
 
 void build_menu_update(gint idx);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list