https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120029

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |15.2.0

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've just realised that we should be able to avoid the loop in the fix:

  // Handle p += *i where i is in [p.begin(),p.end()), for the same reason.
  if (_M_type() == _Type::_Multi && p._M_type() != _Type::_Multi)
    for (const path& cmpt : *this)
      if (&cmpt == &p) [[unlikely]]
        return *this += p.native();

We store each component in a contiguous array, so we can just do:

  if (_M_type() == _Type::_Multi && p._M_type() != _Type::_Multi)
    {
      const auto first = _M_cmpts.begin(), first + _M_cmpts.size();
      if (!std::less<>()(&p, first) && std::less<>()(&p, last)) [[unlikely]]
        return *this += p.native();
    }

Reply via email to