Skip to content

Commit

Permalink
Cleanup: avoid repeated literal strings
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPeshkoff committed Jan 15, 2024
1 parent 837c9ee commit e75923b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/common/IntlUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes,
}

string icuVersion;
map.get("ICU-VERSION", icuVersion);
map.get(ATTR_ICU_VERSION, icuVersion);

string collVersion;
auto icu = UnicodeUtil::getCollVersion(icuVersion, configInfo, collVersion);
Expand All @@ -691,13 +691,13 @@ bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes,
int majorVersion, minorVersion;
UnicodeUtil::getICUVersion(icu, majorVersion, minorVersion);
icuVersion.printf("%d.%d", majorVersion, minorVersion);
map.put("ICU-VERSION", icuVersion);
map.put(ATTR_ICU_VERSION, icuVersion);
}

map.remove("COLL-VERSION");
map.remove(ATTR_COLL_VERSION);

if (collVersion.hasData())
map.put("COLL-VERSION", collVersion);
map.put(ATTR_COLL_VERSION, collVersion);

newSpecificAttributes = IntlUtil::generateSpecificAttributes(charSet, map);
return true;
Expand Down
3 changes: 3 additions & 0 deletions src/common/IntlUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ namespace Firebird
{
class CharSet;

static const char* ATTR_ICU_VERSION = "ICU-VERSION";
static const char* ATTR_COLL_VERSION = "COLL-VERSION";

class IntlUtil
{
public:
Expand Down
4 changes: 2 additions & 2 deletions src/common/unicode_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
++attributeCount;

string collVersion;
if (specificAttributes.get(IntlUtil::convertAsciiToUtf16("COLL-VERSION"), collVersion))
if (specificAttributes.get(IntlUtil::convertAsciiToUtf16(ATTR_COLL_VERSION), collVersion))
{
++attributeCount;

Expand Down Expand Up @@ -1486,7 +1486,7 @@ UnicodeUtil::Utf16Collation* UnicodeUtil::Utf16Collation::create(
tt->texttype_pad_option = (attributes & TEXTTYPE_ATTR_PAD_SPACE) ? true : false;

string icuVersion;
if (specificAttributes.get(IntlUtil::convertAsciiToUtf16("ICU-VERSION"), icuVersion))
if (specificAttributes.get(IntlUtil::convertAsciiToUtf16(ATTR_ICU_VERSION), icuVersion))
icuVersion = IntlUtil::convertUtf16ToAscii(icuVersion, &error);

const auto icu = loadICU(icuVersion, collVersion, locale, configInfo);
Expand Down
4 changes: 2 additions & 2 deletions src/jrd/dfw.epp
Original file line number Diff line number Diff line change
Expand Up @@ -4049,8 +4049,8 @@ static string remove_icu_info_from_attributes(const string& charsetName, const s
if (IntlUtil::parseSpecificAttributes(charSet, specificAttributes.length(),
(const UCHAR*) specificAttributes.begin(), &map))
{
map.remove("ICU-VERSION");
map.remove("COLL-VERSION");
map.remove(ATTR_ICU_VERSION);
map.remove(ATTR_COLL_VERSION);
return IntlUtil::generateSpecificAttributes(charSet, map);
}
}
Expand Down

0 comments on commit e75923b

Please sign in to comment.