[vlc-commits] commit: Speed up vlc_meta_TypeToLocalizedString() ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Thu Oct 7 21:36:32 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct  7 22:35:44 2010 +0300| [8c723814b224f467abdc3d823f74efa25d01ac1c] | committer: Rémi Denis-Courmont 

Speed up vlc_meta_TypeToLocalizedString()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8c723814b224f467abdc3d823f74efa25d01ac1c
---

 src/input/meta.c |   43 +++++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/input/meta.c b/src/input/meta.c
index bff1b7d..a285d70 100644
--- a/src/input/meta.c
+++ b/src/input/meta.c
@@ -26,6 +26,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_playlist.h>
 #include <vlc_url.h>
@@ -47,28 +49,29 @@ struct vlc_meta_t
 /* FIXME bad name convention */
 const char * vlc_meta_TypeToLocalizedString( vlc_meta_type_t meta_type )
 {
-    switch( meta_type )
+    static const char posix_names[][16] =
     {
-    case vlc_meta_Title:        return _("Title");
-    case vlc_meta_Artist:       return _("Artist");
-    case vlc_meta_Genre:        return _("Genre");
-    case vlc_meta_Copyright:    return _("Copyright");
-    case vlc_meta_Album:        return _("Album");
-    case vlc_meta_TrackNumber:  return _("Track number");
-    case vlc_meta_Description:  return _("Description");
-    case vlc_meta_Rating:       return _("Rating");
-    case vlc_meta_Date:         return _("Date");
-    case vlc_meta_Setting:      return _("Setting");
-    case vlc_meta_URL:          return _("URL");
-    case vlc_meta_Language:     return _("Language");
-    case vlc_meta_NowPlaying:   return _("Now Playing");
-    case vlc_meta_Publisher:    return _("Publisher");
-    case vlc_meta_EncodedBy:    return _("Encoded by");
-    case vlc_meta_ArtworkURL:   return _("Artwork URL");
-    case vlc_meta_TrackID:      return _("Track ID");
-
-    default: abort();
-    }
+        [vlc_meta_Title]       = N_("Title"),
+        [vlc_meta_Artist]      = N_("Artist"),
+        [vlc_meta_Genre]       = N_("Genre"),
+        [vlc_meta_Copyright]   = N_("Copyright"),
+        [vlc_meta_Album]       = N_("Album"),
+        [vlc_meta_TrackNumber] = N_("Track number"),
+        [vlc_meta_Description] = N_("Description"),
+        [vlc_meta_Rating]      = N_("Rating"),
+        [vlc_meta_Date]        = N_("Date"),
+        [vlc_meta_Setting]     = N_("Setting"),
+        [vlc_meta_URL]         = N_("URL"),
+        [vlc_meta_Language]    = N_("Language"),
+        [vlc_meta_NowPlaying]  = N_("Now Playing"),
+        [vlc_meta_Publisher]   = N_("Publisher"),
+        [vlc_meta_EncodedBy]   = N_("Encoded by"),
+        [vlc_meta_ArtworkURL]  = N_("Artwork URL"),
+        [vlc_meta_TrackID]     = N_("Track ID"),
+    };
+
+    assert (meta_type < (sizeof(posix_names) / sizeof(posix_names[0])));
+    return vlc_gettext (posix_names[meta_type]);
 };
 
 



More information about the vlc-commits mailing list