Skip to content

Commit

Permalink
Use aggregate init/designed initializers more: /media
Browse files Browse the repository at this point in the history
This allows more variables to be const/constexpr, provides field names,
and allows us to avoid explicitly zeroing.

This CL was uploaded by git cl split.

R=tmathmeyer@chromium.org

Bug: none
Change-Id: I40ce61f01f391608eec7ba4b4b6a814e9b10755d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4862736
Commit-Queue: Ted (Chromium) Meyer <tmathmeyer@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Ted (Chromium) Meyer <tmathmeyer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1196411}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Sep 14, 2023
1 parent 96aa097 commit 8205333
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
14 changes: 4 additions & 10 deletions media/formats/webm/webm_info_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,12 @@ bool WebMInfoParser::OnBinary(int id, const uint8_t* data, int size) {
for (int i = 0; i < size; ++i)
date_in_nanoseconds = (date_in_nanoseconds << 8) | data[i];

base::Time::Exploded exploded_epoch;
exploded_epoch.year = 2001;
exploded_epoch.month = 1;
exploded_epoch.day_of_month = 1;
exploded_epoch.day_of_week = 1;
exploded_epoch.hour = 0;
exploded_epoch.minute = 0;
exploded_epoch.second = 0;
exploded_epoch.millisecond = 0;
static constexpr base::Time::Exploded kExplodedEpoch = {
.year = 2001, .month = 1, .day_of_week = 1, .day_of_month = 1};
base::Time out_time;
if (!base::Time::FromUTCExploded(exploded_epoch, &out_time))
if (!base::Time::FromUTCExploded(kExplodedEpoch, &out_time)) {
return false;
}
date_utc_ = out_time + base::Microseconds(date_in_nanoseconds / 1000);
}
return true;
Expand Down
19 changes: 9 additions & 10 deletions media/test/pipeline_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,16 @@ static base::Time kLiveTimelineOffset() {
// 2012-11-10 12:34:56.789123456
// Since base::Time only has a resolution of microseconds,
// construct a base::Time for 2012-11-10 12:34:56.789123.
base::Time::Exploded exploded_time;
exploded_time.year = 2012;
exploded_time.month = 11;
exploded_time.day_of_month = 10;
exploded_time.day_of_week = 6;
exploded_time.hour = 12;
exploded_time.minute = 34;
exploded_time.second = 56;
exploded_time.millisecond = 789;
static constexpr base::Time::Exploded kExplodedTime = {.year = 2012,
.month = 11,
.day_of_week = 6,
.day_of_month = 10,
.hour = 12,
.minute = 34,
.second = 56,
.millisecond = 789};
base::Time timeline_offset;
EXPECT_TRUE(base::Time::FromUTCExploded(exploded_time, &timeline_offset));
EXPECT_TRUE(base::Time::FromUTCExploded(kExplodedTime, &timeline_offset));

timeline_offset += base::Microseconds(123);

Expand Down

0 comments on commit 8205333

Please sign in to comment.