diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2011-08-05 08:32:08 (GMT) |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2011-08-11 16:58:09 (GMT) |
commit | 3596db6c9bb8db42476d0c7b52fa2043dc67135b (patch) | |
tree | e585bd30bfd329034be5258454d99cc52ed79d2c /src/corelib | |
parent | cb7cb1d3884ae8a032f3ad2ed3a6d8e3ffc06206 (diff) | |
download | Qt-3596db6c9bb8db42476d0c7b52fa2043dc67135b.zip Qt-3596db6c9bb8db42476d0c7b52fa2043dc67135b.tar.gz Qt-3596db6c9bb8db42476d0c7b52fa2043dc67135b.tar.bz2 |
Changed if/if/else/if/eleven chain to switch
Inlined isdigit in switch statement. Removed unused #includes.
Documented unreachable segment with code (Q_ASSERT).
Reviewed-by: Denis Dzyubenko
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qtemporaryfile.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 5bc07cb..9753332 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -53,10 +53,6 @@ # include <errno.h> #endif -#include <stdlib.h> -#include <time.h> -#include <ctype.h> - #if defined(Q_OS_UNIX) # include "private/qcore_unix_p.h" // overrides QT_OPEN #endif @@ -153,23 +149,34 @@ static int createFileFromTemplate(char *const path, for (char *iter = placeholderStart;;) { // Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z' // String progression: "ZZaiC" => "aabiC" - if (*iter == 'Z') { - *iter++ = 'a'; - if (iter == placeholderEnd) - return -1; - } else { - if (isdigit(*iter)) + switch (*iter) { + case 'Z': + // Rollover, advance next character *iter = 'a'; - else if (*iter == 'z') /* inc from z to A */ + if (++iter == placeholderEnd) + return -1; + + continue; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + *iter = 'a'; + break; + + case 'z': + // increment 'z' to 'A' *iter = 'A'; - else { + break; + + default: ++*iter; - } - break; + break; } + break; } } - /*NOTREACHED*/ + + Q_ASSERT(false); } //************* QTemporaryFileEngine |