[1/4] cmd: Avoid checking handle type when already known in WCMD_ReadFile

Juan Lang juan.lang at gmail.com
Tue Oct 4 13:02:38 CDT 2011

> OK but the purpose is to avoid checking the handle type for every line
> read. Granted, one could use '((DWORD_PTR)h) & 3 == 3' instead of
> GetConsoleMode or similar function.
> (there's currently code like "BOOL is_console = GetConsoleMode(...);
> ...; while WCMD_fgets(..., is_console)" and the handle type shouldn't
> change between lines/iterations, so why bother recomputing it every
> time?)

You're probably not.  The compiler will probably inline this function,
or at least its return value, since it knows it's guaranteed not to
change.  Please don't do the compiler's work for it:  IMHO, it's more
readable to make an inline function to determine whether the handle is
a console handle.

More information about the wine-devel mailing list