/pidgin/main: a658571d344d: irc: Store strlen() value to avoid c...

Mike Ruprecht cmaiku at gmail.com
Sun May 15 11:11:27 EDT 2016


Changeset: a658571d344d7933ec09a5c525a3a3299dde347f
Author:	 Mike Ruprecht <cmaiku at gmail.com>
Date:	 2016-05-01 19:34 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/a658571d344d

Description:

irc: Store strlen() value to avoid calling it twice in irc_send_len()

diffstat:

 libpurple/protocols/irc/irc.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (30 lines):

diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -121,6 +121,7 @@ int irc_send(struct irc_conn *irc, const
 int irc_send_len(struct irc_conn *irc, const char *buf, int buflen)
 {
  	char *tosend= g_strdup(buf);
+	int len;
 	GBytes *data;
 
 	purple_signal_emit(_irc_protocol, "irc-sending-text", purple_account_get_connection(irc->account), &tosend);
@@ -128,7 +129,8 @@ int irc_send_len(struct irc_conn *irc, c
 	if (tosend == NULL)
 		return 0;
 
-	data = g_bytes_new_take(tosend, strlen(tosend));
+	len = strlen(tosend);
+	data = g_bytes_new_take(tosend, len);
 	purple_queued_output_stream_push_bytes(irc->output, data);
 	g_bytes_unref(data);
 
@@ -140,7 +142,7 @@ int irc_send_len(struct irc_conn *irc, c
 				purple_account_get_connection(irc->account));
 	}
 
-	return strlen(tosend);
+	return len;
 }
 
 /* XXX I don't like messing directly with these buddies */



More information about the Commits mailing list