Make getFlavor function.

The dangling "else" at the end of #if looked a bit error-prone.
Make it a separate function. No functionality change.