[pulseaudio-commits] r1457 - /trunk/src/pulsecore/log.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun May 27 09:37:06 PDT 2007


Author: lennart
Date: Sun May 27 18:37:05 2007
New Revision: 1457

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1457&root=3Dpulseaudio&vi=
ew=3Drev
Log:
Minor optimization: read log level character code from array

Modified:
    trunk/src/pulsecore/log.c

Modified: trunk/src/pulsecore/log.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/log.c?rev=
=3D1457&root=3Dpulseaudio&r1=3D1456&r2=3D1457&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/log.c (original)
+++ trunk/src/pulsecore/log.c Sun May 27 18:37:05 2007
@@ -62,6 +62,14 @@
 };
 #endif
 =

+static const char level_to_char[] =3D {
+    [PA_LOG_ERROR] =3D 'E',
+    [PA_LOG_WARN] =3D 'W',
+    [PA_LOG_NOTICE] =3D 'N',
+    [PA_LOG_INFO] =3D 'I',
+    [PA_LOG_DEBUG] =3D 'D'
+};
+
 void pa_log_set_ident(const char *p) {
     if (log_ident)
         pa_xfree(log_ident);
@@ -129,7 +137,6 @@
         switch (log_target) {
             case PA_LOG_STDERR: {
                 const char *prefix =3D "", *suffix =3D "";
-                const char *level_code =3D "";
                 char *local_t;
 =

 #ifndef OS_IS_WIN32
@@ -145,33 +152,11 @@
                 }
 #endif
 =

-                switch (level) {
-                    case PA_LOG_ERROR:
-                        level_code =3D "E";
-                        break;
-                    case PA_LOG_WARN:
-                        level_code =3D "W";
-                        break;
-                    case PA_LOG_NOTICE:
-                        level_code =3D "N";
-                        break;
-                    case PA_LOG_INFO:
-                        level_code =3D "I";
-                        break;
-                    case PA_LOG_DEBUG:
-                        level_code =3D "D";
-                        break;
-                    default:
-                        level_code =3D "?";
-                }
-
                 local_t =3D pa_utf8_to_locale(t);
-                if (!local_t) {
-                    fprintf(stderr, "%s: %s%s%s%s\n", level_code, location,
-                        prefix, t, suffix);
-                } else {
-                    fprintf(stderr, "%s: %s%s%s%s\n", level_code, location,
-                        prefix, local_t, suffix);
+                if (!local_t)
+                    fprintf(stderr, "%c: %s%s%s%s\n", level_to_char[level]=
, location, prefix, t, suffix);
+                else {
+                    fprintf(stderr, "%c: %s%s%s%s\n", level_to_char[level]=
, location, prefix, local_t, suffix);
                     pa_xfree(local_t);
                 }
 =





More information about the pulseaudio-commits mailing list