Use aggregate init/designed initializers more: /pdf
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=thestig@chromium.org Bug: none Change-Id: I504768df61790e6955cc46f959df81357fd60e44 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4863784 Commit-Queue: Lei Zhang <thestig@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#1196367}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
187d8a7bc5
commit
90928b71d7
pdf
@ -113,13 +113,13 @@ base::Time ParsePdfDate(base::StringPiece date) {
|
||||
return base::Time();
|
||||
|
||||
// Month and day default to 1. The rest of the parts of a date default to 0.
|
||||
base::Time::Exploded exploded = {};
|
||||
exploded.year = deserialized_year.value();
|
||||
exploded.month = deserializer.PopDigits(2).value_or(1);
|
||||
exploded.day_of_month = deserializer.PopDigits(2).value_or(1);
|
||||
exploded.hour = deserializer.PopDigits(2).value_or(0);
|
||||
exploded.minute = deserializer.PopDigits(2).value_or(0);
|
||||
exploded.second = deserializer.PopDigits(2).value_or(0);
|
||||
base::Time::Exploded exploded = {
|
||||
.year = deserialized_year.value(),
|
||||
.month = deserializer.PopDigits(2).value_or(1),
|
||||
.day_of_month = deserializer.PopDigits(2).value_or(1),
|
||||
.hour = deserializer.PopDigits(2).value_or(0),
|
||||
.minute = deserializer.PopDigits(2).value_or(0),
|
||||
.second = deserializer.PopDigits(2).value_or(0)};
|
||||
|
||||
base::Time parsed;
|
||||
if (!base::Time::FromUTCExploded(exploded, &parsed))
|
||||
|
@ -202,17 +202,15 @@ FPDF_SYSTEMTIME PDFiumFormFiller::Form_GetLocalTime(FPDF_FORMFILLINFO* param) {
|
||||
base::Time time = base::Time::Now();
|
||||
base::Time::Exploded exploded;
|
||||
time.LocalExplode(&exploded);
|
||||
|
||||
FPDF_SYSTEMTIME rv;
|
||||
rv.wYear = exploded.year;
|
||||
rv.wMonth = exploded.month;
|
||||
rv.wDayOfWeek = exploded.day_of_week;
|
||||
rv.wDay = exploded.day_of_month;
|
||||
rv.wHour = exploded.hour;
|
||||
rv.wMinute = exploded.minute;
|
||||
rv.wSecond = exploded.second;
|
||||
rv.wMilliseconds = exploded.millisecond;
|
||||
return rv;
|
||||
return FPDF_SYSTEMTIME{
|
||||
.wYear = static_cast<unsigned short>(exploded.year),
|
||||
.wMonth = static_cast<unsigned short>(exploded.month),
|
||||
.wDayOfWeek = static_cast<unsigned short>(exploded.day_of_week),
|
||||
.wDay = static_cast<unsigned short>(exploded.day_of_month),
|
||||
.wHour = static_cast<unsigned short>(exploded.hour),
|
||||
.wMinute = static_cast<unsigned short>(exploded.minute),
|
||||
.wSecond = static_cast<unsigned short>(exploded.second),
|
||||
.wMilliseconds = static_cast<unsigned short>(exploded.millisecond)};
|
||||
}
|
||||
|
||||
// static
|
||||
|
Reference in New Issue
Block a user