changeset 32624:65bad41adf52

Using g_string_new_len here is unnecessary, and a real waste of calls to strlen.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 17 Sep 2011 06:58:39 +0000
parents 2e8c905a5e74
children 094a1b511259
files pidgin/plugins/adiumthemes/webkit.c
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/plugins/adiumthemes/webkit.c	Sat Sep 17 06:27:35 2011 +0000
+++ b/pidgin/plugins/adiumthemes/webkit.c	Sat Sep 17 06:58:39 2011 +0000
@@ -95,7 +95,6 @@
 static char *
 replace_message_tokens(
 	const char *text,
-	gsize len,
 	PurpleConversation *conv,
 	const char *name,
 	const char *alias,
@@ -103,7 +102,7 @@
 	PurpleMessageFlags flags,
 	time_t mtime)
 {
-	GString *str = g_string_new_len(NULL, len);
+	GString *str = g_string_new(NULL);
 	const char *cur = text;
 	const char *prev = cur;
 
@@ -177,9 +176,9 @@
 }
 
 static char *
-replace_header_tokens(char *text, gsize len, PurpleConversation *conv)
+replace_header_tokens(char *text, PurpleConversation *conv)
 {
-	GString *str = g_string_new_len(NULL, len);
+	GString *str = g_string_new(NULL);
 	char *cur = text;
 	char *prev = cur;
 
@@ -241,9 +240,9 @@
 }
 
 static char *
-replace_template_tokens(PidginMessageStyle *style, char *text, int len, char *header, char *footer)
+replace_template_tokens(PidginMessageStyle *style, char *text, char *header, char *footer)
 {
-	GString *str = g_string_new_len(NULL, len);
+	GString *str = g_string_new(NULL);
 
 	char **ms = g_strsplit(text, "%@", 6);
 	char *base = NULL;
@@ -358,10 +357,10 @@
 
 	basedir = g_build_filename(style->style_dir, "Contents", "Resources", "Template.html", NULL);
 	baseuri = g_strdup_printf("file://%s", basedir);
-	header = replace_header_tokens(style->header_html, strlen(style->header_html), conv);
+	header = replace_header_tokens(style->header_html, conv);
 	g_assert(style);
-	footer = replace_header_tokens(style->footer_html, strlen(style->footer_html), conv);
-	template = replace_template_tokens(style, style->template_html, strlen(style->template_html) + strlen(style->header_html), header, footer);
+	footer = replace_header_tokens(style->footer_html, conv);
+	template = replace_template_tokens(style, style->template_html, header, footer);
 
 	g_assert(template);
 
@@ -452,7 +451,7 @@
 	purple_conversation_set_data(conv, "webkit-lastflags", GINT_TO_POINTER(flags));
 
 	smileyed = smiley_parse_markup(stripped, conv->account->protocol_id);
-	msg = replace_message_tokens(message_html, 0, conv, name, alias, smileyed, flags, mtime);
+	msg = replace_message_tokens(message_html, conv, name, alias, smileyed, flags, mtime);
 	escape = gtk_webview_quote_js_string(msg);
 	script = g_strdup_printf("%s(%s)", func, escape);