-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Description
llvm-project/libcxx/include/print
Lines 235 to 241 in 2f4328e
__vprint_unicode_posix(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) { | |
// TODO PRINT Should flush errors throw too? | |
if (__is_terminal) | |
std::fflush(__stream); | |
__print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl); | |
} |
In this function the following two lines are not necessary and introduce performance pessimization.
llvm-project/libcxx/include/print
Lines 237 to 238 in 2f4328e
if (__is_terminal) | |
std::fflush(__stream); |
Additionally, if you read the standard carefully http://www.eel.is/c++draft/print.fun#7.sentence-4 It says:
If the native Unicode API is used, the function flushes stream before writing out.
Although POSIX offers a way to query if a C stream goes to terminal or not, it does not have native Unicode API, so such API is never used, and flushing is not needed. A consequence of this is that on POSIX querying the C stream is not needed at all and it is another performance pessimization. The call to __is_terminal()
is not needed here.
llvm-project/libcxx/include/print
Lines 312 to 313 in 2f4328e
# ifndef _WIN32 | |
__print::__vprint_unicode_posix(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream)); |