[all-commits] [llvm/llvm-project] 9ae059: [ADT] Refactor MapVector::insert, try_emplace, and...

Kazu Hirata via All-commits all-commits at lists.llvm.org
Mon Aug 25 09:37:50 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9ae059bc22a49fb233a62837b6dc91004882b918
      https://github.com/llvm/llvm-project/commit/9ae059bc22a49fb233a62837b6dc91004882b918
  Author: Kazu Hirata <kazu at google.com>
  Date:   2025-08-25 (Mon, 25 Aug 2025)

  Changed paths:
    M llvm/include/llvm/ADT/MapVector.h

  Log Message:
  -----------
  [ADT] Refactor MapVector::insert, try_emplace, and operator[] (NFC) (#155205)

The l-value and r-value reference variants of try_emplace contain
nearly identical code.  Also, operator[] makes its own call to
Map.try_emplace.

This patch introduces a templated helper function, try_emplace_impl,
and uses it in all of MapVector::insert, try_emplace, and operator[].
The helper function uses perfect forwarding to preserve the exact key
type.

This patch moves the "private:" section to the end of the class so
that the new helper function can use iterator.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list