changeset 22771:5954c65ae4f4

Don't count the size of an array at runtime if it's known at compile time.
author Ethan Blanton <elb@pidgin.im>
date Wed, 30 Apr 2008 17:00:27 +0000
parents cc8903c59d6b
children 7e28f2b64982
files libpurple/protocols/jabber/usermood.c
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/usermood.c	Wed Apr 30 08:46:51 2008 +0000
+++ b/libpurple/protocols/jabber/usermood.c	Wed Apr 30 17:00:27 2008 +0000
@@ -147,7 +147,7 @@
 
 static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) {
 	JabberStream *js;
-	int max_mood_idx;
+	const int max_mood_idx = sizeof(moodstrings) / sizeof(moodstrings[0]) - 1;
 	int selected_mood = purple_request_fields_get_choice(fields, "mood");
 
 	if (!PURPLE_CONNECTION_IS_VALID(gc)) {
@@ -157,9 +157,6 @@
 
 	js = gc->proto_data;
 
-	/* This is ugly, but protects us from unexpected values. */
-	for (max_mood_idx = 0; moodstrings[max_mood_idx]; max_mood_idx++);
-
 	if (selected_mood < 0 || selected_mood >= max_mood_idx) {
 		purple_debug_error("jabber", "Invalid mood index (%d) selected.\n", selected_mood);
 		return;