Skip to content

Commit ac54b96

Browse files
committed
Fix conversion warning in TimeZoneUtil
+ constexpr and some noexcept
1 parent 273b5e6 commit ac54b96

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/common/TimeZoneUtil.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ namespace
101101
//-------------------------------------
102102

103103
static const TimeZoneDesc* getDesc(USHORT timeZone);
104-
static inline bool isOffset(USHORT timeZone);
105-
static inline SSHORT offsetZoneToDisplacement(USHORT timeZone);
106-
static inline USHORT displacementToOffsetZone(SSHORT displacement);
107-
static int parseNumber(const char*& p, const char* end);
108-
static void skipSpaces(const char*& p, const char* end);
104+
static inline bool isOffset(USHORT timeZone) noexcept;
105+
static inline SSHORT offsetZoneToDisplacement(USHORT timeZone) noexcept;
106+
static inline USHORT displacementToOffsetZone(SSHORT displacement) noexcept;
107+
static int parseNumber(const char*& p, const char* end) noexcept;
108+
static void skipSpaces(const char*& p, const char* end) noexcept;
109109

110110
//-------------------------------------
111111

@@ -140,7 +140,7 @@ namespace
140140
fb_utils::readenv(ICU_TIMEZONE_FILES_DIR, path);
141141
}
142142

143-
const PathName& get()
143+
const PathName& get() noexcept
144144
{
145145
return path;
146146
}
@@ -175,7 +175,7 @@ namespace
175175
}
176176
}
177177

178-
const ObjectsArray<TimeZoneDesc>& getTimeZoneList()
178+
const ObjectsArray<TimeZoneDesc>& getTimeZoneList() noexcept
179179
{
180180
return timeZoneList;
181181
}
@@ -298,7 +298,7 @@ namespace
298298

299299
static const UDate MIN_ICU_TIMESTAMP = TimeZoneUtil::timeStampToIcuDate(TimeStamp::MIN_TIMESTAMP);
300300
static const UDate MAX_ICU_TIMESTAMP = TimeZoneUtil::timeStampToIcuDate(TimeStamp::MAX_TIMESTAMP);
301-
static const unsigned ONE_DAY = 24 * 60 - 1; // used for offset encoding
301+
static constexpr unsigned ONE_DAY = 24 * 60 - 1; // used for offset encoding
302302
static InitInstance<TimeZoneDataPath> timeZoneDataPath;
303303
static InitInstance<TimeZoneStartup> timeZoneStartup;
304304

@@ -347,7 +347,7 @@ USHORT TimeZoneUtil::getSystemTimeZone()
347347
if (configDefault && configDefault[0])
348348
{
349349
str = configDefault;
350-
len = strlen(str);
350+
len = static_cast<int32_t>(strlen(str));
351351
}
352352
else
353353
{
@@ -1154,26 +1154,26 @@ static const TimeZoneDesc* getDesc(USHORT timeZone)
11541154
}
11551155

11561156
// Returns true if the time zone is offset-based or false if region-based.
1157-
static inline bool isOffset(USHORT timeZone)
1157+
static inline bool isOffset(USHORT timeZone) noexcept
11581158
{
11591159
return timeZone <= ONE_DAY * 2;
11601160
}
11611161

11621162
// Gets the displacement from a offset-based time zone id.
1163-
static inline SSHORT offsetZoneToDisplacement(USHORT timeZone)
1163+
static inline SSHORT offsetZoneToDisplacement(USHORT timeZone) noexcept
11641164
{
11651165
fb_assert(isOffset(timeZone));
11661166

11671167
return (SSHORT) (int(timeZone) - ONE_DAY);
11681168
}
11691169

1170-
static inline USHORT displacementToOffsetZone(SSHORT displacement)
1170+
static inline USHORT displacementToOffsetZone(SSHORT displacement) noexcept
11711171
{
11721172
return (USHORT)(int(displacement) + ONE_DAY);
11731173
}
11741174

11751175
// Parses a integer number.
1176-
static int parseNumber(const char*& p, const char* end)
1176+
static int parseNumber(const char*& p, const char* end) noexcept
11771177
{
11781178
const char* start = p;
11791179
int n = 0;
@@ -1188,7 +1188,7 @@ static int parseNumber(const char*& p, const char* end)
11881188
}
11891189

11901190
// Skip spaces and tabs.
1191-
static void skipSpaces(const char*& p, const char* end)
1191+
static void skipSpaces(const char*& p, const char* end) noexcept
11921192
{
11931193
while (p < end && (*p == ' ' || *p == '\t'))
11941194
++p;

src/common/TimeZoneUtil.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,17 @@ class IcuCalendarWrapper
176176
IcuCalendarWrapper& operator=(const IcuCalendarWrapper&) = delete;
177177

178178
public:
179-
UCalendar* operator->()
179+
UCalendar* operator->() noexcept
180180
{
181181
return wrapped;
182182
}
183183

184-
operator UCalendar*()
184+
operator UCalendar*() noexcept
185185
{
186186
return wrapped;
187187
}
188188

189-
bool operator!() const
189+
bool operator!() const noexcept
190190
{
191191
return !wrapped;
192192
}

0 commit comments

Comments
 (0)