Skip to content

Commit 78d9fe2

Browse files
committed
mapstring: optimize msStringToUpper(), msStringToLower()
Traverse the string only once. Also, this removes code which triggered -Wsign-compare.
1 parent d82a348 commit 78d9fe2

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

mapstring.c

+4-12
Original file line numberDiff line numberDiff line change
@@ -377,25 +377,17 @@ char *msIntToString(int value)
377377

378378
void msStringToUpper(char *string)
379379
{
380-
int i;
381-
382380
if (string != NULL) {
383-
for (i = 0; i < strlen(string); i++) {
384-
string[i] = toupper(string[i]);
385-
}
386-
return;
381+
for (; *string; ++string)
382+
*string = toupper(*string);
387383
}
388384
}
389385

390386
void msStringToLower(char *string)
391387
{
392-
int i;
393-
394388
if (string != NULL) {
395-
for (i = 0; i < strlen(string); i++) {
396-
string[i] = tolower(string[i]);
397-
}
398-
return;
389+
for (; *string; ++string)
390+
*string = tolower(*string);
399391
}
400392
}
401393

0 commit comments

Comments
 (0)