Web lists-archives.com

Re: [MPlayer-dev-eng] [PATCH] gui/menu: optimize language table.




Reimar Döffinger wrote on Sat, 13 Feb 2016 23:50:48 +0100:

> Store fixed size 4 entry directly
> instead of via pointer.
>  gui/dialog/menu.c | 2 +-

> - const char * id2;
> + const char id2[4];

This patch should do better.

Ingo
Index: gui/dialog/menu.c
===================================================================
--- gui/dialog/menu.c	(revision 37705)
+++ gui/dialog/menu.c	(working copy)
@@ -230,7 +230,7 @@
 typedef struct
 {
  int id;
- const char * id2;
+ const char id2[3];
  const char * name;
 } Languages_t;
 
@@ -438,7 +438,7 @@
     else if ( p[3] != 0) return language;
   }
  for ( i=0;i<sizeof( Languages ) / sizeof( Languages_t );i++ )
-  if ( type == GET_LANG_INT ? Languages[i].id == l : strcasecmp(Languages[i].id2, p) == 0 ) return Languages[i].name;
+  if ( type == GET_LANG_INT ? Languages[i].id == l : strncasecmp(Languages[i].id2, p, FF_ARRAY_ELEMS(Languages[i].id2)) == 0 ) return Languages[i].name;
  return MSGTR_GUI_Unknown;
 }
 #undef lng
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng