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

    <tr>
        <th>Summary</th>
        <td>
            [libc++] Low-hanging fruit optimizations in `std::is_permutation`
        </td>
    </tr>

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

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

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

<pre>
    There's a place in `std::is_permutation` where we eliminate a common prefix at the start. We could use `std::mismatch` instead of a hand-written loop, since `mismatch` is vectorized.

Inside `__is_permutation_impl`, we can use `std::find` for "Have we already counted the number of `*__i` in `[f1, l1)`?"
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEkk2L3DwMgH-NcxEzJEoy2RxymN1leF_osdDjoNjKRMUfwXZmuvvrS9KFdumhYDAW0iM9RpSS3DzzoNpn1b4WtOY5xMEaCd5zMQbzNnydObLCLgHBYkkziAd1KlM2qj6r-izpunB0a6YswatTCY-tBB4MbMWJp8xAoINzwcMSeZIfQBnyzJAyxXyEbww6rNbAmvgT20lylPW8UcWnzGQgTEAwkzeHR5Sc2YMNYVH4Akm83us_lSW4s84hyjuboyrPqjz_75OYPfN6_Tz-Vdxi1anccA8GTf6vmSbxZgNPIYJC_I_uuyvZyGTeNhGf2ex6fnUjx23iHXm-XuWXyf5un6dq62Mrhf0WqC8KsTBDbfq6p4KHqmvKrntqOyzmodJ9Ry3iSMxY9mjGri37ZhyfmBrdN4UMWGJbIj5hVZ8qPHJFzaSxx_LUmWZsVFOyI7FHa-_uGOKtkJRWHirsa2wKSyPbtO8CopVRK3zeDyp8UYgLxylER17zFmtfizhspMO43pJqSispp9_sLNnum_UHqn2FL-FxmMnfxN9giqtkCEsWJ-_7_6d_blexRjvMOS9pS8CLwstN8ryORx2cwsvW_-M6LDF8Z50VXnbRpPDy4Xof8GcAAAD__wDT8y8">