[MPlayer-cvslog] r34265 - trunk/gui/util/string.c
ib
subversion at mplayerhq.hu
Wed Oct 26 17:52:06 CEST 2011
Author: ib
Date: Wed Oct 26 17:52:06 2011
New Revision: 34265
Log:
Optimize TranslateFilename().
Replace for loop with index by while loop with pointer.
Unite the if conditions.
Modified:
trunk/gui/util/string.c
Modified: trunk/gui/util/string.c
==============================================================================
--- trunk/gui/util/string.c Wed Oct 26 17:40:47 2011 (r34264)
+++ trunk/gui/util/string.c Wed Oct 26 17:52:06 2011 (r34265)
@@ -249,7 +249,6 @@ void setddup(char **old, const char *dir
*/
char *TranslateFilename(int how, char *fname, size_t maxlen)
{
- int i;
char *p;
size_t len;
@@ -305,18 +304,18 @@ char *TranslateFilename(int how, char *f
}
if (how) {
- for (i = 0; fname[i]; i++) {
- int t = 0;
+ p = fname;
- if (how == 1)
- if (fname[i] >= 'A' && fname[i] <= 'Z')
- t = 32;
+ while (*p) {
+ char t = 0;
- if (how == 2)
- if (fname[i] >= 'a' && fname[i] <= 'z')
- t = -32;
+ if (how == 1 && *p >= 'A' && *p <= 'Z')
+ t = 32;
+ if (how == 2 && *p >= 'a' && *p <= 'z')
+ t = -32;
- fname[i] = (char)(fname[i] + t);
+ *p = *p + t;
+ p++;
}
}
More information about the MPlayer-cvslog
mailing list