Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Issue 1408403002: Introduce rtc::ArrayView<T>, which keeps track of an array that it doesn't own (Closed)

Created:
5 years, 2 months ago by kwiberg-webrtc
Modified:
5 years, 1 month ago
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Introduce rtc::ArrayView<T>, which keeps track of an array that it doesn't own The main intended use case is as a function argument, replacing the harder-to-read and harder-to-use separate pointer and size arguments. It's easier to read because it's just one argument instead of two, and with clearly defined semantics; it's easier to use because it has iterators, and will automatically figure out the size of arrays. BUG=webrtc:5028 R=andrew@webrtc.org, solenberg@webrtc.org Committed: https://crrev.com/e2a83eee7337e5a8244c7abacc552bf5ef344442 Cr-Commit-Position: refs/heads/master@{#10415}

Patch Set 1 #

Patch Set 2 : The last element is end - 1, not end #

Patch Set 3 : Avoid implicit size_t -> char conversion #

Patch Set 4 : Implicit conversion to ArrayView from many types #

Patch Set 5 : Improve tests #

Total comments: 6

Patch Set 6 : Death test for out-of-bounds indexing #

Patch Set 7 : Windows compile fix #

Total comments: 12

Patch Set 8 : Review comments + some free extras #

Patch Set 9 : Paranoid Edition #

Total comments: 4

Patch Set 10 : Check invariants only in constructor #

Total comments: 2

Patch Set 11 : Nominal singularization of invariant check #

Patch Set 12 : Check one more thing in operator[] #

Patch Set 13 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+306 lines, -0 lines) Patch
M webrtc/base/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -0 lines 0 comments Download
A webrtc/base/array_view.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +84 lines, -0 lines 0 comments Download
A webrtc/base/array_view_unittest.cc View 1 2 3 4 5 6 7 1 chunk +217 lines, -0 lines 0 comments Download
M webrtc/base/base.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -0 lines 0 comments Download
M webrtc/base/base_tests.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -0 lines 0 comments Download
M webrtc/base/checks.h View 1 2 3 4 5 6 2 chunks +2 lines, -0 lines 0 comments Download

Messages

Total messages: 40 (7 generated)
kwiberg-webrtc
5 years, 2 months ago (2015-10-19 11:59:01 UTC) #3
the sun
On 2015/10/19 11:59:01, kwiberg-webrtc wrote: > ☘ Neat! Yes, questions: 1. What are the differences ...
5 years, 2 months ago (2015-10-19 12:14:36 UTC) #4
kwiberg-webrtc
On 2015/10/19 12:14:36, the sun wrote: > On 2015/10/19 11:59:01, kwiberg-webrtc wrote: > > ☘ ...
5 years, 2 months ago (2015-10-19 12:29:59 UTC) #5
the sun
On 2015/10/19 12:29:59, kwiberg-webrtc wrote: > On 2015/10/19 12:14:36, the sun wrote: > > On ...
5 years, 2 months ago (2015-10-19 12:37:29 UTC) #6
tommi
On 2015/10/19 11:59:01, kwiberg-webrtc wrote: > ☘ ( ‘-’)人(゚_゚ )
5 years, 2 months ago (2015-10-19 12:41:49 UTC) #7
kwiberg-webrtc
On 2015/10/19 12:37:29, the sun wrote: > On 2015/10/19 12:29:59, kwiberg-webrtc wrote: > > On ...
5 years, 2 months ago (2015-10-19 12:44:34 UTC) #8
the sun
On 2015/10/19 12:44:34, kwiberg-webrtc wrote: > On 2015/10/19 12:37:29, the sun wrote: > > On ...
5 years, 2 months ago (2015-10-19 14:35:11 UTC) #9
Andrew MacDonald
+Michael, who was considering importing ArraySlice into webrtc: https://cs.corp.google.com/#piper///depot/google3/util/gtl/array_slice.h We'd talked about replacing some of ...
5 years, 2 months ago (2015-10-19 16:41:29 UTC) #11
kwiberg-webrtc
On 2015/10/19 16:41:29, Andrew MacDonald wrote: > +Michael, who was considering importing ArraySlice into webrtc: ...
5 years, 2 months ago (2015-10-19 17:40:10 UTC) #12
the sun
https://codereview.webrtc.org/1408403002/diff/80001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/80001/webrtc/base/array_view.h#newcode60 webrtc/base/array_view.h:60: // mutation, use ArrayView<const T>.) Why not add clearly ...
5 years, 2 months ago (2015-10-21 10:53:43 UTC) #13
kwiberg-webrtc
https://codereview.webrtc.org/1408403002/diff/80001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/80001/webrtc/base/array_view.h#newcode60 webrtc/base/array_view.h:60: // mutation, use ArrayView<const T>.) On 2015/10/21 10:53:42, the ...
5 years, 2 months ago (2015-10-21 12:08:55 UTC) #14
kwiberg-webrtc
All reviewers: I feel pretty much done at this point. Anything still missing? https://codereview.webrtc.org/1408403002/diff/80001/webrtc/base/array_view_unittest.cc File ...
5 years, 2 months ago (2015-10-21 12:45:24 UTC) #15
hlundin-webrtc
You've got plenty of solid reviewers without me. Removing myself.
5 years, 2 months ago (2015-10-21 13:15:13 UTC) #16
the sun
https://codereview.webrtc.org/1408403002/diff/120001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/120001/webrtc/base/array_view.h#newcode30 webrtc/base/array_view.h:30: ArrayView() : ArrayView(static_cast<T*>(nullptr), 0) {} Is the cast really ...
5 years, 2 months ago (2015-10-21 14:06:35 UTC) #18
mgraczyk
I am okay with ArrayView not being immutable as long as we remember that the ...
5 years, 2 months ago (2015-10-22 00:12:27 UTC) #19
Andrew MacDonald
lgtm with the other reviewer's comments addressed.
5 years, 2 months ago (2015-10-22 02:47:32 UTC) #20
kwiberg-webrtc
New patch set posted with review comment fixes + some new stuff (tests that call ...
5 years, 2 months ago (2015-10-22 11:35:33 UTC) #21
the sun
https://codereview.webrtc.org/1408403002/diff/120001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/120001/webrtc/base/array_view.h#newcode62 webrtc/base/array_view.h:62: T* data() const { return data_; } On 2015/10/22 ...
5 years, 2 months ago (2015-10-22 12:02:49 UTC) #22
kwiberg-webrtc
New patch set posted. https://codereview.webrtc.org/1408403002/diff/120001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/120001/webrtc/base/array_view.h#newcode62 webrtc/base/array_view.h:62: T* data() const { return ...
5 years, 2 months ago (2015-10-22 13:07:00 UTC) #23
kwiberg-webrtc
On 2015/10/22 00:12:27, mgraczyk wrote: > I am okay with ArrayView not being immutable as ...
5 years, 2 months ago (2015-10-22 13:36:09 UTC) #24
the sun
https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h#newcode89 webrtc/base/array_view.h:89: void CheckInvariants() const { RTC_DCHECK_EQ(!data_, size_ == 0); } ...
5 years, 2 months ago (2015-10-22 13:42:23 UTC) #25
kwiberg-webrtc
https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h#newcode89 webrtc/base/array_view.h:89: void CheckInvariants() const { RTC_DCHECK_EQ(!data_, size_ == 0); } ...
5 years, 2 months ago (2015-10-22 13:54:54 UTC) #26
the sun
lgtm https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h#newcode89 webrtc/base/array_view.h:89: void CheckInvariants() const { RTC_DCHECK_EQ(!data_, size_ == 0); ...
5 years, 2 months ago (2015-10-22 14:29:49 UTC) #27
the sun
https://codereview.webrtc.org/1408403002/diff/180001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/180001/webrtc/base/array_view.h#newcode76 webrtc/base/array_view.h:76: void CheckInvariants() const { RTC_DCHECK_EQ(!data_, size_ == 0); } ...
5 years, 2 months ago (2015-10-22 14:31:30 UTC) #28
Andrew MacDonald
Karl, you might send out a webrtc-eng PSA after this lands. ArrayView and Maybe will ...
5 years, 2 months ago (2015-10-22 16:22:14 UTC) #29
kwiberg-webrtc
Depluralizing patch set posted https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h File webrtc/base/array_view.h (right): https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h#newcode89 webrtc/base/array_view.h:89: void CheckInvariants() const { RTC_DCHECK_EQ(!data_, ...
5 years, 2 months ago (2015-10-22 20:58:01 UTC) #30
the sun
On 2015/10/22 20:58:01, kwiberg-webrtc wrote: > Depluralizing patch set posted > > https://codereview.webrtc.org/1408403002/diff/160001/webrtc/base/array_view.h > File ...
5 years, 2 months ago (2015-10-22 21:16:33 UTC) #31
kwiberg-webrtc
On 2015/10/22 21:16:33, the sun wrote: > On 2015/10/22 20:58:01, kwiberg-webrtc wrote: > > You ...
5 years, 2 months ago (2015-10-22 22:03:45 UTC) #32
the sun
On 2015/10/22 22:03:45, kwiberg-webrtc wrote: > On 2015/10/22 21:16:33, the sun wrote: > > On ...
5 years, 1 month ago (2015-10-26 12:05:19 UTC) #33
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1408403002/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1408403002/220001
5 years, 1 month ago (2015-10-26 12:12:36 UTC) #36
commit-bot: I haz the power
Try jobs failed on following builders: presubmit on tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/presubmit/builds/1406)
5 years, 1 month ago (2015-10-26 12:17:32 UTC) #38
kwiberg-webrtc
Committed patchset #13 (id:240001) manually as e2a83eee7337e5a8244c7abacc552bf5ef344442 (presubmit successful).
5 years, 1 month ago (2015-10-26 18:51:47 UTC) #39
commit-bot: I haz the power
5 years, 1 month ago (2015-10-26 18:51:52 UTC) #40
Message was sent while issue was closed.
Patchset 13 (id:??) landed as
https://crrev.com/e2a83eee7337e5a8244c7abacc552bf5ef344442
Cr-Commit-Position: refs/heads/master@{#10415}

Powered by Google App Engine
This is Rietveld 408576698