Mercurial > pidgin
diff libpurple/protocols/jabber/usermood.c @ 22795: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 | 665e04562de0 |
children | 26eabe8e739b 5f9a24d1c25e 432d9176d054 |
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;