pidgin: 9f33b5ce: Don't use strlen() when you're just chec...

markdoliner at pidgin.im markdoliner at pidgin.im
Sun Aug 21 22:25:59 EDT 2011


----------------------------------------------------------------------
Revision: 9f33b5ce2c74e058158c6c9964d6abba2dff8dc6
Parent:   ad72e4ca88b0e10549536c1edb35064462d0fc92
Author:   markdoliner at pidgin.im
Date:     08/21/11 22:11:36
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9f33b5ce2c74e058158c6c9964d6abba2dff8dc6

Changelog: 

Don't use strlen() when you're just checking whether a string is
empty

Changes against parent ad72e4ca88b0e10549536c1edb35064462d0fc92

  patched  libpurple/protocols/gg/buddylist.c
  patched  libpurple/protocols/mxit/login.c
  patched  libpurple/protocols/mxit/profile.c
  patched  libpurple/protocols/mxit/voicevideo.c
  patched  libpurple/protocols/null/nullprpl.c
  patched  libpurple/protocols/zephyr/zephyr.c
  patched  pidgin/gtkconv.c

-------------- next part --------------
============================================================
--- libpurple/protocols/zephyr/zephyr.c	ce70e656b5705d4b8882d7c223c6454b75d91e84
+++ libpurple/protocols/zephyr/zephyr.c	b33993e182a9633a5fea940ac81e572ed92084c8
@@ -1164,7 +1164,7 @@ static gint check_notify_tzc(gpointer da
 				locations = find_node(newparsetree,"locations");
 				locval = tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents;
 
-				if (!locval || !g_ascii_strcasecmp(locval," ") || (strlen(locval) == 0)) {
+				if (!locval || !g_ascii_strcasecmp(locval," ") || !*locval) {
 					nlocs = 0;
 				} else {
 					nlocs = 1;
============================================================
--- pidgin/gtkconv.c	607a4f7e015c4d1ae18d0edfc018ec20df299037
+++ pidgin/gtkconv.c	803b53a6cc5ba36e948ddb4b6951ff51add54bce
@@ -578,7 +578,7 @@ send_cb(GtkWidget *widget, PidginConvers
 
 	gtk_widget_grab_focus(gtkconv->entry);
 
-	if (strlen(clean) == 0) {
+	if (!*clean) {
 		g_free(buf);
 		g_free(clean);
 		return;
============================================================
--- libpurple/protocols/gg/buddylist.c	7dfeee613c00f65de04631594a9fdf5b3c06ab4f
+++ libpurple/protocols/gg/buddylist.c	c631da14f7e92be7a74e58f5c63ff61974c5e3a8
@@ -90,7 +90,7 @@ void ggp_buddylist_load(PurpleConnection
 		gchar **data_tbl;
 		gchar *name, *show, *g;
 
-		if (strlen(users_tbl[i]) == 0)
+		if (!*users_tbl[i])
 			continue;
 
 		data_tbl = g_strsplit(users_tbl[i], ";", 8);
============================================================
--- libpurple/protocols/null/nullprpl.c	b9249aebbf0ed48faae0d654e3adb129173179dc
+++ libpurple/protocols/null/nullprpl.c	05be395e5c95930d2d8baa349ffbb5e724b054b9
@@ -781,10 +781,10 @@ static PurpleCmdRet send_whisper(PurpleC
   to_username = args[0];
   message = args[1];
 
-  if (!to_username || strlen(to_username) == 0) {
+  if (!to_username || !*to_username) {
     *error = g_strdup(_("Whisper is missing recipient."));
     return PURPLE_CMD_RET_FAILED;
-  } else if (!message || strlen(message) == 0) {
+  } else if (!message || !*message) {
     *error = g_strdup(_("Whisper is missing message."));
     return PURPLE_CMD_RET_FAILED;
   }
============================================================
--- libpurple/protocols/mxit/login.c	5e374d2d40456c3b11cf8d9eb6ec2a3da31f53be
+++ libpurple/protocols/mxit/login.c	c7e21c05defc7a351d65a40f5374043f3efd4c62
@@ -743,7 +743,7 @@ void mxit_login( PurpleAccount* account 
 	 * if we don't have any info saved from a previous login, we need to get it from the MXit WAP site.
 	 * we do cache it, so this step is only done on the very first login for each account.
 	 */
-	if ( ( session->distcode == NULL ) || ( strlen( session->distcode ) == 0 ) ) {
+	if ( ( session->distcode == NULL ) || ( !*session->distcode ) ) {
 		/* this must be the very first login, so we need to retrieve the user information */
 		get_clientinfo( session );
 	}
============================================================
--- libpurple/protocols/mxit/profile.c	7092fb1bd098be55eb308444e9d6f879911dd822
+++ libpurple/protocols/mxit/profile.c	57b53b2467d279f961ea095f8fb3c4cae9eb01a7
@@ -115,7 +115,7 @@ static int calculateAge( const char* dat
 	struct tm now, bdate;
 	int age;
 
-	if ( ( !date ) || ( strlen( date ) == 0 ) )
+	if ( ( !date ) || ( !*date ) )
 		return 0;
 
 	/* current time */
============================================================
--- libpurple/protocols/mxit/voicevideo.c	cc45d420d931abc446d23fb2a3990b129a3a79b6
+++ libpurple/protocols/mxit/voicevideo.c	9f8067b027c3d3099abf07c10e464fe20257ec6f
@@ -71,7 +71,7 @@ PurpleMediaCaps mxit_media_caps(PurpleAc
 	purple_debug_info(MXIT_PLUGIN_ID, "mxit_media_caps: buddy '%s'\n", who);
 
 	/* We need to have a voice/video server */
-	if (strlen(session->voip_server) == 0)
+	if (!*session->voip_server)
 		return PURPLE_MEDIA_CAPS_NONE;
 
 	/* find the buddy information for this contact (reference: "libpurple/blist.h") */


More information about the Commits mailing list