Chromium Code Reviews

Issue 1896833004: rtc::Optional<T>: Don't secretly contain a default-constructed T when empty (Closed)

Created:
4 years, 8 months ago by kwiberg-webrtc
Modified:
4 years, 7 months ago
Reviewers:
tommi, pthatcher1
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com, the sun
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

rtc::Optional<T>: Don't secretly contain a default-constructed T when empty Instead, use a neat trick with union to ensure that we have a T only when we're supposed to (and just a bunch of unused memory otherwise). This is how std::optional behaves, so it makes sense for us to do the same (and it's convenient, too, since we don't have to pay for the default-constructed T, and we support types that don't have default constructors). Doing this became possible recently when we dropped support for MSVC 2013, which didn't support unions containing non-trivial types. Committed: https://crrev.com/d040480f69cc6fe65dd101c493d0561a0cdbaa4a Cr-Commit-Position: refs/heads/master@{#12664}

Patch Set 1 : #

Patch Set 2 : rebase #

Unified diffs Side-by-side diffs Stats (+134 lines, -82 lines)
M webrtc/base/optional.h View 3 chunks +90 lines, -20 lines 0 comments
M webrtc/base/optional_unittest.cc View 14 chunks +44 lines, -62 lines 0 comments

Messages

Total messages: 19 (11 generated)
kwiberg-webrtc
I've had this lying around since before Optional was initially landed, but it didn't work ...
4 years, 8 months ago (2016-04-19 01:52:33 UTC) #5
kwiberg-webrtc
+tommi@ Also, bringing up the question of potentially dropping our Optional implementation (and therefore this ...
4 years, 7 months ago (2016-05-06 02:01:43 UTC) #7
tommi
lgtm. that' pretty neat.
4 years, 7 months ago (2016-05-06 07:42:05 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1896833004/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1896833004/20001
4 years, 7 months ago (2016-05-09 08:04:48 UTC) #10
commit-bot: I haz the power
Try jobs failed on following builders: android_compile_x64_dbg on tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/android_compile_x64_dbg/builds/3792) android_gn_rel on tryserver.webrtc (JOB_FAILED, ...
4 years, 7 months ago (2016-05-09 08:05:59 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1896833004/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1896833004/40001
4 years, 7 months ago (2016-05-09 11:02:14 UTC) #15
commit-bot: I haz the power
Committed patchset #2 (id:40001)
4 years, 7 months ago (2016-05-09 13:06:10 UTC) #17
commit-bot: I haz the power
4 years, 7 months ago (2016-05-09 13:06:16 UTC) #19
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/d040480f69cc6fe65dd101c493d0561a0cdbaa4a
Cr-Commit-Position: refs/heads/master@{#12664}

Powered by Google App Engine