Add contains() to some //base classes [chromium/src : main]

0 views
Skip to first unread message

Victor Vianna (Gerrit)

unread,
Jan 7, 2026, 3:16:22 PM (2 days ago) Jan 7
to Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, bmcquad...@chromium.org, chromeos-gfx-...@google.com, chromium-a...@chromium.org, csharris...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jshin...@chromium.org, loading-rev...@chromium.org, media-cro...@chromium.org, oshima...@chromium.org, performance-m...@chromium.org, speed-metrics...@chromium.org, speed-metr...@chromium.org, vaapi-...@chromium.org
Attention needed from Daniel Cheng

Victor Vianna voted and added 3 comments

Votes added by Victor Vianna

Auto-Submit+1

3 comments

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Victor Vianna . resolved

PTAL

File base/containers/small_map.h
File-level comment, Patchset 4 (Latest):
Victor Vianna . resolved

Please add OO+1

File mojo/public/cpp/bindings/lib/multiplex_router.cc
Line 14, Patchset 4 (Latest):#include "base/containers/contains.h"
Victor Vianna . resolved

This one is still used, so the CL keeps it

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I0cc1ccdb51f74de1e54ca862bde82733a6e80e48
Gerrit-Change-Number: 7378870
Gerrit-PatchSet: 4
Gerrit-Owner: Victor Vianna <victor...@google.com>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Victor Vianna <victor...@google.com>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Wed, 07 Jan 2026 20:16:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Victor Vianna (Gerrit)

unread,
Jan 7, 2026, 3:55:47 PM (2 days ago) Jan 7
to Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, bmcquad...@chromium.org, chromeos-gfx-...@google.com, chromium-a...@chromium.org, csharris...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jshin...@chromium.org, loading-rev...@chromium.org, media-cro...@chromium.org, oshima...@chromium.org, performance-m...@chromium.org, speed-metrics...@chromium.org, speed-metr...@chromium.org, vaapi-...@chromium.org
Attention needed from Daniel Cheng

Victor Vianna voted and added 2 comments

Votes added by Victor Vianna

Auto-Submit+1

2 comments

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Victor Vianna . resolved

Converted a few extra instances

File mojo/public/cpp/bindings/lib/multiplex_router.cc
Line 14, Patchset 5 (Latest):#include "base/containers/contains.h"
Victor Vianna . resolved

This one is still used, so the CL keeps it

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I0cc1ccdb51f74de1e54ca862bde82733a6e80e48
Gerrit-Change-Number: 7378870
Gerrit-PatchSet: 5
Gerrit-Owner: Victor Vianna <victor...@google.com>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Victor Vianna <victor...@google.com>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Wed, 07 Jan 2026 20:55:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Daniel Cheng (Gerrit)

unread,
Jan 7, 2026, 4:19:42 PM (2 days ago) Jan 7
to Victor Vianna, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, bmcquad...@chromium.org, chromeos-gfx-...@google.com, chromium-a...@chromium.org, csharris...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jshin...@chromium.org, loading-rev...@chromium.org, media-cro...@chromium.org, oshima...@chromium.org, performance-m...@chromium.org, speed-metrics...@chromium.org, speed-metr...@chromium.org, vaapi-...@chromium.org
Attention needed from Victor Vianna

Daniel Cheng added 3 comments

File base/containers/small_map.h
Line 374, Patchset 5 (Latest): constexpr bool contains(const key_type& key) const {
Daniel Cheng . unresolved

This should support heterogeneous lookup.

File base/containers/small_map_unittest.cc
Line 590, Patchset 5 (Latest): small_map<std::unordered_map<int, int>> m;
Daniel Cheng . unresolved

Please pick a container other than std::unordered_map here. I don't care strongly which one, but we have guidance that discourages new std::unordered_map use.

File base/containers/variant_map.h
Line 281, Patchset 5 (Latest): bool contains(const Key& key) const { return find(key) != end(); }
Daniel Cheng . unresolved

Ditto: this was probably an oversight when we introduced variant map, but we should not persist this mistake for the new contains() method.

Open in Gerrit

Related details

Attention is currently required from:
  • Victor Vianna
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0cc1ccdb51f74de1e54ca862bde82733a6e80e48
    Gerrit-Change-Number: 7378870
    Gerrit-PatchSet: 5
    Gerrit-Owner: Victor Vianna <victor...@google.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Victor Vianna <victor...@google.com>
    Gerrit-Attention: Victor Vianna <victor...@google.com>
    Gerrit-Comment-Date: Wed, 07 Jan 2026 21:19:32 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Victor Vianna (Gerrit)

    unread,
    Jan 7, 2026, 5:15:00 PM (2 days ago) Jan 7
    to Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, bmcquad...@chromium.org, chromeos-gfx-...@google.com, chromium-a...@chromium.org, csharris...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jshin...@chromium.org, loading-rev...@chromium.org, media-cro...@chromium.org, oshima...@chromium.org, performance-m...@chromium.org, speed-metrics...@chromium.org, speed-metr...@chromium.org, vaapi-...@chromium.org
    Attention needed from Daniel Cheng

    Victor Vianna voted and added 3 comments

    Votes added by Victor Vianna

    Auto-Submit+1

    3 comments

    File base/containers/small_map.h
    Line 374, Patchset 5: constexpr bool contains(const key_type& key) const {
    Daniel Cheng . resolved

    This should support heterogeneous lookup.

    Victor Vianna

    I just learned about heterogenous lookup, hopefully I got it right.

    File base/containers/small_map_unittest.cc
    Line 590, Patchset 5: small_map<std::unordered_map<int, int>> m;
    Daniel Cheng . resolved

    Please pick a container other than std::unordered_map here. I don't care strongly which one, but we have guidance that discourages new std::unordered_map use.

    Victor Vianna

    Done

    File base/containers/variant_map.h
    Line 281, Patchset 5: bool contains(const Key& key) const { return find(key) != end(); }
    Daniel Cheng . unresolved

    Ditto: this was probably an oversight when we introduced variant map, but we should not persist this mistake for the new contains() method.

    Attention is currently required from:
    • Daniel Cheng
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0cc1ccdb51f74de1e54ca862bde82733a6e80e48
    Gerrit-Change-Number: 7378870
    Gerrit-PatchSet: 7
    Gerrit-Owner: Victor Vianna <victor...@google.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Victor Vianna <victor...@google.com>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Wed, 07 Jan 2026 22:14:54 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Cheng (Gerrit)

    unread,
    Jan 8, 2026, 4:16:28 PM (18 hours ago) Jan 8
    to Victor Vianna, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, bmcquad...@chromium.org, chromeos-gfx-...@google.com, chromium-a...@chromium.org, csharris...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jshin...@chromium.org, loading-rev...@chromium.org, media-cro...@chromium.org, oshima...@chromium.org, performance-m...@chromium.org, speed-metrics...@chromium.org, speed-metr...@chromium.org, vaapi-...@chromium.org
    Attention needed from Victor Vianna

    Daniel Cheng added 2 comments

    File base/containers/small_map.h
    Line 341, Patchset 7 (Latest): constexpr iterator find(const T& key) {
    Daniel Cheng . unresolved

    You shouldn't change this; while we didn't hit it here, there are times when the non-template overload would be used (typically when template deduction would otherwise fail)

    I'd just leave this as-is and add a TODO amd address it in a followup.

    File base/containers/variant_map.h
    Line 281, Patchset 5: bool contains(const Key& key) const { return find(key) != end(); }
    Daniel Cheng . resolved

    Ditto: this was probably an oversight when we introduced variant map, but we should not persist this mistake for the new contains() method.

    Victor Vianna

    VariantMap currently has no EqualKey template param
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/variant_map.h;l=74;drc=1b049924c0f9432e31d6987e085a656c66bf94dc

    Are you proposing I copy this to VariantMap?
    https://source.chromium.org/chromium/chromium/src/+/main:base/containers/small_map.h;l=105-151;drc=134ef9afcaff9644ce859d61752d3ef51b924eb6

    Daniel Cheng

    Ah... maybe it's a bit hard for `VariantMap` because one subtype is ordered and the other is not.

    Let's just ignore this, since it's supposed to be removed in M145.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Victor Vianna
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0cc1ccdb51f74de1e54ca862bde82733a6e80e48
    Gerrit-Change-Number: 7378870
    Gerrit-PatchSet: 7
    Gerrit-Owner: Victor Vianna <victor...@google.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Victor Vianna <victor...@google.com>
    Gerrit-Attention: Victor Vianna <victor...@google.com>
    Gerrit-Comment-Date: Thu, 08 Jan 2026 21:16:17 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Victor Vianna <victor...@google.com>
    Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Victor Vianna (Gerrit)

    unread,
    Jan 8, 2026, 4:23:32 PM (18 hours ago) Jan 8
    to Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, bmcquad...@chromium.org, chromeos-gfx-...@google.com, chromium-a...@chromium.org, csharris...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jshin...@chromium.org, loading-rev...@chromium.org, media-cro...@chromium.org, oshima...@chromium.org, performance-m...@chromium.org, speed-metrics...@chromium.org, speed-metr...@chromium.org, vaapi-...@chromium.org
    Attention needed from Daniel Cheng

    Victor Vianna added 2 comments

    File base/containers/small_map.h
    Line 376, Patchset 7 (Latest): constexpr bool contains(const key_type& key) const {
    return find(key) != end();
    }
    Victor Vianna . unresolved

    Do I even need this given the one below?

    Line 341, Patchset 7 (Latest): constexpr iterator find(const T& key) {
    Daniel Cheng . unresolved

    You shouldn't change this; while we didn't hit it here, there are times when the non-template overload would be used (typically when template deduction would otherwise fail)

    I'd just leave this as-is and add a TODO amd address it in a followup.

    Victor Vianna

    Sorry, the suggestion is not clear to me. If I don't have templated find(), how am I gonna implement contains()? Do you want me to duplicate+adapt the find's method body in contains?

    If you just want a `constexpr iterator find(const key_type& key)`, I can do that in this patch already

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0cc1ccdb51f74de1e54ca862bde82733a6e80e48
    Gerrit-Change-Number: 7378870
    Gerrit-PatchSet: 7
    Gerrit-Owner: Victor Vianna <victor...@google.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Victor Vianna <victor...@google.com>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Thu, 08 Jan 2026 21:23:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Cheng (Gerrit)

    unread,
    Jan 8, 2026, 7:16:39 PM (15 hours ago) Jan 8
    to Victor Vianna, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, bmcquad...@chromium.org, chromeos-gfx-...@google.com, chromium-a...@chromium.org, csharris...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jshin...@chromium.org, loading-rev...@chromium.org, media-cro...@chromium.org, oshima...@chromium.org, performance-m...@chromium.org, speed-metrics...@chromium.org, speed-metr...@chromium.org, vaapi-...@chromium.org
    Attention needed from Victor Vianna

    Daniel Cheng added 1 comment

    File base/containers/small_map.h
    Line 341, Patchset 7 (Latest): constexpr iterator find(const T& key) {
    Daniel Cheng . unresolved

    You shouldn't change this; while we didn't hit it here, there are times when the non-template overload would be used (typically when template deduction would otherwise fail)

    I'd just leave this as-is and add a TODO amd address it in a followup.

    Victor Vianna

    Sorry, the suggestion is not clear to me. If I don't have templated find(), how am I gonna implement contains()? Do you want me to duplicate+adapt the find's method body in contains?

    If you just want a `constexpr iterator find(const key_type& key)`, I can do that in this patch already

    Daniel Cheng

    Oh right, `find()` is missing this and that's what `contains()` uses. It's probably easiest to duplicate it then; I don't think it's specified if the wrapped map is ordered or not.

    Otherwise I would have suggested the trick that flat_tree uses: https://chromium-review.googlesource.com/c/chromium/src/+/7163836

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Victor Vianna
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0cc1ccdb51f74de1e54ca862bde82733a6e80e48
    Gerrit-Change-Number: 7378870
    Gerrit-PatchSet: 7
    Gerrit-Owner: Victor Vianna <victor...@google.com>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Victor Vianna <victor...@google.com>
    Gerrit-Attention: Victor Vianna <victor...@google.com>
    Gerrit-Comment-Date: Fri, 09 Jan 2026 00:16:29 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages