From b7345f1f997c12c1e4c8a0d11c4cd8f4b585b5c0 Mon Sep 17 00:00:00 2001 From: pouillot Date: Sat, 28 Aug 2010 13:48:44 +0000 Subject: [PATCH] small code cleanup and optimization git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2706 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 793133ce0b7d78393cdf8529063b47042500e603 Former-commit-id: 60aae87f15e8ea8de2ffd2710f5cc8150903da45 --- src/modules/graphic/ssggraph/grtexture.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/modules/graphic/ssggraph/grtexture.cpp b/src/modules/graphic/ssggraph/grtexture.cpp index efa859d26..4c798ee5c 100644 --- a/src/modules/graphic/ssggraph/grtexture.cpp +++ b/src/modules/graphic/ssggraph/grtexture.cpp @@ -28,8 +28,7 @@ int doMipMap(const char *tfname, int mipmap) { - char *buf = (char *) malloc(strlen(tfname)+1); - strcpy(buf, tfname); + char *buf = strdup(tfname); // find the filename extension. char *s = strrchr(buf, '.'); @@ -40,23 +39,21 @@ int doMipMap(const char *tfname, int mipmap) // search for the texture parameters. s = strrchr(buf, '_'); - // no mipmap for "_n" and "shadow". - if (s) { - // check the "_n". - if (strncmp(s, "_n", 4) == 0) { - mipmap = FALSE; - } + // 1) no mipmap for "*_n". + if (s && s[1] == 'n') { + mipmap = FALSE; } + // 1) no mipmap for "*shadow*". if (mipmap) { // Check the shadow. s = strrchr((char *)tfname, '/'); if (!s) { - s = (char *) tfname; + s = (char*)tfname; } else { s++; } - if (strstr(s, "shadow") != NULL) { + if (strstr(s, "shadow")) { mipmap = FALSE; } }