Dolphin, the GameCube and Wii emulator - Forums

Full Version: Code Something odd..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

When i noticed the latest update it said silly typo so i wanted to check what it was,
btw it was a silly typo..

But while browsing tru the file i noticed,

Code:
bool IsHexDigit(char c) {
    switch (c) {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
        case 'a':
        case 'b':
        case 'c':
        case 'd':
        case 'e':
        case 'f':
            return true;
        default:
            return false;
    }
}

bool IsAlpha(char c) {
    return (c >= 'A' && c <= 'Z') ||
           (c >= 'a' && c <= 'z');
}

Notice how isAplha is being handled and isHexDigit ?
Its about the same but done diffrently is this done for a speed purpose ?
If not couldnt you just use

Code:
// lower case only
bool IsHexDigit(char c) {
    return (c >= '0' && c <= 'f');
}


bool IsAlpha(char c) {
    return (c >= 'A' && c <= 'Z') ||
           (c >= 'a' && c <= 'z');
}

I would say it looks alot cleaner :/.