[mafw-lastfm-devel] [PATCH mafw-lastfm 12/12] Shorten names of static functions

Felipe Contreras felipe.contreras at gmail.com
Thu Jan 14 18:33:58 EET 2010


No need to add long prefixes.

Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
 mafw-lastfm/mafw-lastfm-scrobbler.c |   37 +++++++++++++++++------------------
 mafw-lastfm/mafw-lastfm.c           |   20 +++++++++---------
 2 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/mafw-lastfm/mafw-lastfm-scrobbler.c b/mafw-lastfm/mafw-lastfm-scrobbler.c
index c38c86b..d783819 100644
--- a/mafw-lastfm/mafw-lastfm-scrobbler.c
+++ b/mafw-lastfm/mafw-lastfm-scrobbler.c
@@ -63,8 +63,8 @@ struct MafwLastfmScrobblerPrivate {
 
 static MafwLastfmTrack *
 mafw_lastfm_track_encode (MafwLastfmTrack *track);
-static gboolean mafw_lastfm_track_cmp (MafwLastfmTrack *a,
-                                       MafwLastfmTrack *b);
+static gboolean track_cmp (MafwLastfmTrack *a,
+                           MafwLastfmTrack *b);
 static  MafwLastfmTrack *
 mafw_lastfm_track_dup (MafwLastfmTrack *track);
 
@@ -73,7 +73,7 @@ static void handshake_cb (SoupSession *session,
                           gpointer user_data);
 
 static void
-mafw_lastfm_scrobbler_finalize (GObject *object)
+finalize (GObject *object)
 {
   MafwLastfmScrobblerPrivate *priv = MAFW_LASTFM_SCROBBLER (object)->priv;
 
@@ -109,7 +109,7 @@ mafw_lastfm_scrobbler_class_init (MafwLastfmScrobblerClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   g_type_class_add_private (klass, sizeof (MafwLastfmScrobblerPrivate));
 
-  object_class->finalize = mafw_lastfm_scrobbler_finalize;
+  object_class->finalize = finalize;
 }
 
 static void
@@ -170,8 +170,8 @@ on_deferred_handshake_timeout_cb (gpointer user_data)
   return FALSE;
 }
 
-static void
-mafw_lastfm_scrobbler_defer_handshake (MafwLastfmScrobbler *scrobbler)
+static inline void
+defer_handshake (MafwLastfmScrobbler *scrobbler)
 {
   if (scrobbler->priv->handshake_id != 0)
     return;
@@ -183,7 +183,7 @@ mafw_lastfm_scrobbler_defer_handshake (MafwLastfmScrobbler *scrobbler)
 }
 
 static void
-mafw_lastfm_scrobbler_scrobbling_failed (MafwLastfmScrobbler *scrobbler)
+scrobbling_failed (MafwLastfmScrobbler *scrobbler)
 {
   GList *iter;
 
@@ -195,7 +195,7 @@ mafw_lastfm_scrobbler_scrobbling_failed (MafwLastfmScrobbler *scrobbler)
   g_list_free (scrobbler->priv->scrobble_list);
   scrobbler->priv->scrobble_list = NULL;
 
-  mafw_lastfm_scrobbler_defer_handshake (scrobbler);
+  defer_handshake (scrobbler);
 }
 
 static void
@@ -206,22 +206,22 @@ scrobble_cb (SoupSession *session,
   if (SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
     g_print ("Scrobble: %s", message->response_body->data);
     if (strcmp (message->response_body->data, "BADSESSION\n") == 0)
-      mafw_lastfm_scrobbler_scrobbling_failed (MAFW_LASTFM_SCROBBLER (user_data));
+      scrobbling_failed (MAFW_LASTFM_SCROBBLER (user_data));
   } else {
-    mafw_lastfm_scrobbler_scrobbling_failed (MAFW_LASTFM_SCROBBLER (user_data));
+    scrobbling_failed (MAFW_LASTFM_SCROBBLER (user_data));
   }
 }
 
 /**
- * mafw_lastfm_scrobbler_scrobble_list:
+ * scrobble_list:
  * @scrobbler: a scrobbler
  * @list: a %NULL-terminated list of %MafwLastfmTrack elements
  *
  * Submits a series of tracks from the list.
  **/
 static void
-mafw_lastfm_scrobbler_scrobble_list (MafwLastfmScrobbler *scrobbler,
-                                     GList *list)
+scrobble_list (MafwLastfmScrobbler *scrobbler,
+               GList *list)
 {
   gint i;
   GList *iter;
@@ -271,7 +271,7 @@ set_playing_now_cb (SoupSession *session,
   if (SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
     g_print ("Playing-now: %s", message->response_body->data);
     if (strcmp (message->response_body->data, "BADSESSION\n") == 0)
-      mafw_lastfm_scrobbler_defer_handshake (scrobbler);
+      defer_handshake (scrobbler);
   }
 }
 
@@ -325,7 +325,7 @@ scrobble_real (MafwLastfmScrobbler *scrobbler)
 
   if (list) {
     scrobbler->priv->scrobble_list = list;
-    mafw_lastfm_scrobbler_scrobble_list (scrobbler, list);
+    scrobble_list (scrobbler, list);
   }
 }
 
@@ -406,8 +406,7 @@ mafw_lastfm_scrobbler_enqueue_scrobble (MafwLastfmScrobbler *scrobbler,
   }
 
   if (scrobbler->priv->suspended_track) {
-    if (mafw_lastfm_track_cmp (scrobbler->priv->suspended_track,
-                               encoded)) {
+    if (track_cmp (scrobbler->priv->suspended_track, encoded)) {
       mafw_lastfm_track_free (encoded);
       encoded = scrobbler->priv->suspended_track;
     } else {
@@ -609,8 +608,8 @@ mafw_lastfm_track_encode (MafwLastfmTrack *track)
 }
 
 static gboolean
-mafw_lastfm_track_cmp (MafwLastfmTrack *a,
-                       MafwLastfmTrack *b)
+track_cmp (MafwLastfmTrack *a,
+           MafwLastfmTrack *b)
 {
   return (strcmp (a->artist, b->artist) == 0 &&
           strcmp (a->title, b->title) == 0 &&
diff --git a/mafw-lastfm/mafw-lastfm.c b/mafw-lastfm/mafw-lastfm.c
index dc14f0e..f633e4a 100644
--- a/mafw-lastfm/mafw-lastfm.c
+++ b/mafw-lastfm/mafw-lastfm.c
@@ -30,18 +30,18 @@
 
 gint64 length;
 
-static gchar *
-mafw_metadata_lookup_string (GHashTable *table,
-                             const gchar *key)
+static inline gchar *
+lookup_string (GHashTable *table,
+               const gchar *key)
 {
   GValue *value;
   value = mafw_metadata_first (table, key);
   return value ?  g_value_dup_string (value) : NULL;
 }
 
-static int
-mafw_metadata_lookup_int (GHashTable *table,
-                          const gchar *key)
+static inline int
+lookup_int (GHashTable *table,
+            const gchar *key)
 {
   GValue *value;
   value = mafw_metadata_first (table, key);
@@ -65,8 +65,8 @@ metadata_callback (MafwRenderer *self,
 
   track = mafw_lastfm_track_new ();
 
-  track->artist = mafw_metadata_lookup_string (metadata, MAFW_METADATA_KEY_ARTIST);
-  track->title = mafw_metadata_lookup_string (metadata, MAFW_METADATA_KEY_TITLE);
+  track->artist = lookup_string (metadata, MAFW_METADATA_KEY_ARTIST);
+  track->title = lookup_string (metadata, MAFW_METADATA_KEY_TITLE);
 
   if (!track->artist || !track->title)
     return;
@@ -74,8 +74,8 @@ metadata_callback (MafwRenderer *self,
   track->timestamp = time_val.tv_sec; /* This should probably be obtained in the
                                          state changed cb */
   track->source = 'P';
-  track->album = mafw_metadata_lookup_string (metadata, MAFW_METADATA_KEY_ALBUM);
-  track->number = mafw_metadata_lookup_int (metadata, MAFW_METADATA_KEY_TRACK);
+  track->album = lookup_string (metadata, MAFW_METADATA_KEY_ALBUM);
+  track->number = lookup_int (metadata, MAFW_METADATA_KEY_TRACK);
   track->length = length;
 
   mafw_lastfm_scrobbler_enqueue_scrobble (scrobbler, track);
-- 
1.6.6


More information about the mafw-lastfm-devel mailing list