Skip to content

Commit 86234bf

Browse files
committed
constexpr/noexcept in IntlUtil
1 parent 786a733 commit 86234bf

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/common/IntlUtil.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace
4242
{
4343
struct TextTypeImpl
4444
{
45-
TextTypeImpl(charset* a_cs, UnicodeUtil::Utf16Collation* a_collation)
45+
TextTypeImpl(charset* a_cs, UnicodeUtil::Utf16Collation* a_collation) noexcept
4646
: cs(a_cs),
4747
collation(a_collation)
4848
{
@@ -65,8 +65,8 @@ namespace
6565
namespace Firebird {
6666

6767

68-
static void unicodeDestroy(texttype* tt);
69-
static USHORT unicodeKeyLength(texttype* tt, USHORT len);
68+
static void unicodeDestroy(texttype* tt) noexcept;
69+
static USHORT unicodeKeyLength(texttype* tt, USHORT len) noexcept;
7070
static USHORT unicodeStrToKey(texttype* tt, USHORT srcLen, const UCHAR* src,
7171
USHORT dstLen, UCHAR* dst, USHORT keyType);
7272
static SSHORT unicodeCompare(texttype* tt, ULONG len1, const UCHAR* str1,
@@ -96,11 +96,11 @@ string IntlUtil::generateSpecificAttributes(Firebird::CharSet* cs, SpecificAttri
9696
UCHAR c[sizeof(ULONG)];
9797
ULONG size;
9898

99-
SpecificAttribute* attribute = accessor.current();
99+
const SpecificAttribute* attribute = accessor.current();
100100

101101
s += escapeAttribute(cs, attribute->first);
102102

103-
const USHORT equalChar = '=';
103+
constexpr USHORT equalChar = '=';
104104

105105
size = cs->getConvFromUnicode().convert(
106106
sizeof(equalChar), (const UCHAR*) &equalChar, sizeof(c), c);
@@ -113,7 +113,7 @@ string IntlUtil::generateSpecificAttributes(Firebird::CharSet* cs, SpecificAttri
113113

114114
if (found)
115115
{
116-
const USHORT semiColonChar = ';';
116+
constexpr USHORT semiColonChar = ';';
117117
size = cs->getConvFromUnicode().convert(
118118
sizeof(semiColonChar), (const UCHAR*) &semiColonChar, sizeof(c), c);
119119

@@ -240,7 +240,7 @@ string IntlUtil::convertAsciiToUtf16(const string& ascii)
240240

241241
for (const char* p = ascii.c_str(); p < end; ++p)
242242
{
243-
USHORT c = *(UCHAR*) p;
243+
const USHORT c = *(UCHAR*) p;
244244
s.append((char*) &c, sizeof(c));
245245
}
246246

@@ -388,7 +388,7 @@ ULONG IntlUtil::cvtUtf16ToUtf8(csconvert* obj, ULONG nSrc, const UCHAR* ppSrc,
388388
}
389389

390390

391-
INTL_BOOL IntlUtil::asciiWellFormed(charset* cs, ULONG len, const UCHAR* str, ULONG* offendingPos)
391+
INTL_BOOL IntlUtil::asciiWellFormed(charset* cs, ULONG len, const UCHAR* str, ULONG* offendingPos) noexcept
392392
{
393393
fb_assert(cs != NULL);
394394
fb_assert(str != NULL);
@@ -446,7 +446,7 @@ ULONG IntlUtil::utf8SubString(charset* cs, ULONG srcLen, const UCHAR* src, ULONG
446446
++currentPos;
447447
}
448448

449-
unsigned size = src + pos - copyStart;
449+
const unsigned size = src + pos - copyStart;
450450

451451
fb_assert(size <= dstLen);
452452
if (size > dstLen)
@@ -725,7 +725,7 @@ string IntlUtil::escapeAttribute(Firebird::CharSet* cs, const string& s)
725725
*(USHORT*) uc = '\\';
726726
UCHAR bytes[sizeof(ULONG)];
727727

728-
ULONG bytesSize = cs->getConvFromUnicode().convert(
728+
const ULONG bytesSize = cs->getConvFromUnicode().convert(
729729
sizeof(USHORT), uc, sizeof(bytes), bytes);
730730

731731
ret.append(string((const char*)bytes, bytesSize));
@@ -790,16 +790,16 @@ bool IntlUtil::readAttributeChar(Firebird::CharSet* cs, const UCHAR** s, const U
790790
}
791791

792792

793-
static void unicodeDestroy(texttype* tt)
793+
static void unicodeDestroy(texttype* tt) noexcept
794794
{
795795
delete[] const_cast<ASCII*>(tt->texttype_name);
796796
delete static_cast<TextTypeImpl*>(tt->texttype_impl);
797797
}
798798

799799

800-
static USHORT unicodeKeyLength(texttype* tt, USHORT len)
800+
static USHORT unicodeKeyLength(texttype* tt, USHORT len) noexcept
801801
{
802-
TextTypeImpl* impl = static_cast<TextTypeImpl*>(tt->texttype_impl);
802+
const TextTypeImpl* impl = static_cast<TextTypeImpl*>(tt->texttype_impl);
803803
return impl->collation->keyLength(len / impl->cs->charset_max_bytes_per_char * 4);
804804
}
805805

@@ -827,7 +827,7 @@ static USHORT unicodeStrToKey(texttype* tt, USHORT srcLen, const UCHAR* src,
827827
&errorCode,
828828
&offendingPos));
829829

830-
ULONG utf16Len = cs->charset_to_unicode.csconvert_fn_convert(
830+
const ULONG utf16Len = cs->charset_to_unicode.csconvert_fn_convert(
831831
&cs->charset_to_unicode,
832832
srcLen,
833833
src,

src/common/IntlUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class IntlUtil
7070
static ULONG cvtUtf16ToUtf8(csconvert* obj, ULONG nSrc, const UCHAR* pSrc,
7171
ULONG nDest, UCHAR* pDest, USHORT* err_code, ULONG* err_position);
7272

73-
static INTL_BOOL asciiWellFormed(charset* cs, ULONG len, const UCHAR* str, ULONG* offendingPos);
73+
static INTL_BOOL asciiWellFormed(charset* cs, ULONG len, const UCHAR* str, ULONG* offendingPos) noexcept;
7474
static INTL_BOOL utf8WellFormed(charset* cs, ULONG len, const UCHAR* str, ULONG* offendingPos);
7575

7676
static ULONG utf8SubString(charset* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,

0 commit comments

Comments
 (0)