<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70142>70142</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc++] __vprint_unicode_posix() has unnecessary call to fflush()
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dimztimz
      </td>
    </tr>
</table>

<pre>
    https://github.com/llvm/llvm-project/blob/2f4328e6979004fbf531d69a40c2e06d43d3128c/libcxx/include/print#L235-L241

In this function the following two lines are not necessary and introduce performance pessimization.

https://github.com/llvm/llvm-project/blob/2f4328e6979004fbf531d69a40c2e06d43d3128c/libcxx/include/print#L237-L238

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.

https://github.com/llvm/llvm-project/blob/2f4328e6979004fbf531d69a40c2e06d43d3128c/libcxx/include/print#L312-L313 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVM2L6zYQ_2uUyxAjj-zEPuSQfdtAYKEP2kJvQbZGsYoi5ekj2exfX-S8vN0tpdBTe_EHkmZ-XxoZozk6og1rn1j7vJA5TT5slDm9JXN6Wwxe3TZTSufIxJbhjuHuaNKUh2r0J4Y7ay-P1_Ic_B80Joa7wfqB4Q51I7CjVb_uOW_0oFtRq1UvGz4i8ZVqhBI1dmMpYIbx9ZXhzrjRZkUMd-dgXGIoXlC0yxdsasafGd_en3sHaTIRdHZjMr78EWhvrb8ad4R09WCNowgyEDifwNFIMcpwA-kUGJeCV3kkOFPQPpykm79jNCfzJkvF6mO7_1yB9fIFRfcR0lYpU3BKa28Mv4DRcPMZAkk1ixGTdEoGBaMMpLO1NygsfpC4Xq8Vka1MZLgbGT4xfFJB6vRoXOnsGIp1FcklciMtG9gniPI2K_EBChM_wV7PXZ1M5kLwmzOjVwTbr3swEXIkVTDOJj0c0zbHiSLEFEieYCDtA8E1mFQc9Dl9cmBr0-TzcYKvP_-y_x281hQiSLjKGyQP3zKFW9FAwpdHxaOnWNYShZNx0oIPJQqzWAlUWS3JmOTl73CXbdFDzOP0oOHoQuEHmZKjmUOBa-L3lJEiVcEWRu8ifctFN_D6HlYTIU0ygXffWcyo57xO9I77Uy2QCaS199SmsiadTxOFf0gu_DoRjOVU8sBW_HAw8fBQgWHHsGcr_pc-EwX6P2Ve1Lh8EbWAhdoI1YteLmhTr_qu7rq-4YtpI9ayXdVdKxo9tLUYcd1ht5Zqzeuu7dbDwmyQo6g5Nih4z3klm1qIrh_aXvWy5cgaTidpbFWYVD4cFybGTJs1rxtcWDmQjfNkRCxQ75eEIZZJGTYz_SEfI2u4NTHF9zLJJDvP1A_H2mc4HC4zv0O-5-xw9tG83h2BSUbI7n1OPQzUc8jumxY52H8_jmdS5ZrPvP4MAAD__7d86uI">