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

Mike Ruprecht <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: a658571d344d7933ec09a5c525a3a3299dde347f
Author:	 Mike Ruprecht <[email protected]>
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 */

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.