Micro-optimize QDate::{long,short}{Day,Month}Name()
Save one return statement per function. I don't see why the compiler can't fuse these itself, but apparently it cannot, since this transformation saves 72B in text size. Change-Id: I3a661456554bf451ed53110ad546946ff7b84ec5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
613449a58d
commit
1e824bb9c4
|
|
@ -628,14 +628,13 @@ int QDate::weekNumber(int *yearNumber) const
|
|||
|
||||
QString QDate::shortMonthName(int month, QDate::MonthNameType type)
|
||||
{
|
||||
if (month < 1 || month > 12)
|
||||
return QString();
|
||||
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().monthName(month, QLocale::ShortFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
|
||||
if (month >= 1 || month <= 12) {
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().monthName(month, QLocale::ShortFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
@ -673,14 +672,13 @@ QString QDate::shortMonthName(int month, QDate::MonthNameType type)
|
|||
|
||||
QString QDate::longMonthName(int month, MonthNameType type)
|
||||
{
|
||||
if (month < 1 || month > 12)
|
||||
return QString();
|
||||
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().monthName(month, QLocale::LongFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
|
||||
if (month >= 1 && month <= 12) {
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().monthName(month, QLocale::LongFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneMonthName(month, QLocale::LongFormat);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
@ -713,14 +711,13 @@ QString QDate::longMonthName(int month, MonthNameType type)
|
|||
|
||||
QString QDate::shortDayName(int weekday, MonthNameType type)
|
||||
{
|
||||
if (weekday < 1 || weekday > 7)
|
||||
return QString();
|
||||
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().dayName(weekday, QLocale::ShortFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
|
||||
if (weekday >= 1 && weekday <= 7) {
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().dayName(weekday, QLocale::ShortFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
@ -753,14 +750,13 @@ QString QDate::shortDayName(int weekday, MonthNameType type)
|
|||
|
||||
QString QDate::longDayName(int weekday, MonthNameType type)
|
||||
{
|
||||
if (weekday < 1 || weekday > 7)
|
||||
return QString();
|
||||
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().dayName(weekday, QLocale::LongFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
|
||||
if (weekday >= 1 && weekday <= 7) {
|
||||
switch (type) {
|
||||
case QDate::DateFormat:
|
||||
return QLocale::system().dayName(weekday, QLocale::LongFormat);
|
||||
case QDate::StandaloneFormat:
|
||||
return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue