[tracker/miner-userguide: 7/12] tracker-miner-userguies: Avoid unnecessary string copies



commit 80e3f2b4d804cadf1fd03eb4b6d043a11fc28796
Author: JÃrg Billeter <j bitron ch>
Date:   Thu Nov 24 10:46:41 2011 +0100

    tracker-miner-userguies: Avoid unnecessary string copies

 src/miners/fs/tracker-miner-userguides.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-userguides.c b/src/miners/fs/tracker-miner-userguides.c
index 700ca53..2d8e91d 100644
--- a/src/miners/fs/tracker-miner-userguides.c
+++ b/src/miners/fs/tracker-miner-userguides.c
@@ -536,19 +536,17 @@ parser_characters (void          *ctx,
                    int            len G_GNUC_UNUSED)
 {
 	ParserContext *pctx = ctx;
-	gchar *str;
+	const gchar *str;
 	int len_to_append;
 
 	if (pctx->in_title) {
-		gchar *title = g_strdup ((const gchar *) ch);
+		const gchar *title = (const gchar *) ch;
 
 		if (title[0]) {
 			g_string_append_len (pctx->title,
 			                     title,
 			                     MIN(strlen (title), MAX_TITLE_LENGTH));
 		}
-
-		g_free(title);
 	}
 
 	if (!pctx->in_text) {
@@ -559,10 +557,9 @@ parser_characters (void          *ctx,
 		return;
 	}
 
-	str = g_strdup ((const gchar *) ch);
+	str = (const gchar *) ch;
 
 	if (!str || !str[0]) {
-		g_free (str);
 		return;
 	}
 
@@ -573,7 +570,6 @@ parser_characters (void          *ctx,
 	}
 
 	g_string_append_len (pctx->plain_text, str, len_to_append);
-	g_free (str);
 }
 
 static void



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