Add a presubmit rule for subspan(0u, n).
Using first(n) is shorter and can give better code in most cases. Change-Id: I10747631af5f2d9d18fc57b5e25d49e99b83b377 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6288446 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org> Cr-Commit-Position: refs/heads/main@{#1423283}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
4d79612f46
commit
d3272cd6cb
@ -1993,6 +1993,15 @@ _BANNED_CPP_FUNCTIONS: Sequence[BanRule] = (
|
||||
'^ios/',
|
||||
),
|
||||
),
|
||||
BanRule(
|
||||
pattern=r'subspan(0u,',
|
||||
explanation=
|
||||
('Prefer first(n) over subspan(0u, n) as it is shorter, and the '
|
||||
'compiler may have to emit a branch for the n == dynamic_extent '
|
||||
'case of subspan().',
|
||||
),
|
||||
treat_as_error=False,
|
||||
),
|
||||
BanRule(
|
||||
pattern=r'UNSAFE_TODO(',
|
||||
explanation=
|
||||
|
Reference in New Issue
Block a user