You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-06-20 01:17:49 +02:00
Remove generated StringIds from parse.auto.c.inc.
These StringIds use space and increase churn when new ids are added. It is easy and efficient to use strings for comparison and convert to StringId in code.
This commit is contained in:
@@ -374,7 +374,7 @@ static String *
|
||||
bldCfgRenderScalar(const String *const scalar, const String *const optType)
|
||||
{
|
||||
if (strEq(optType, OPT_TYPE_STRING_ID_STR))
|
||||
return strNewFmt("PARSE_RULE_VAL_STRID(%s)", strZ(bldEnum("", scalar)));
|
||||
return strNewFmt("PARSE_RULE_VAL_STRID(%s)", strZ(bldCfgRenderEnumStr(scalar)));
|
||||
|
||||
if (strEq(optType, OPT_TYPE_STRING_STR))
|
||||
return strNewFmt("PARSE_RULE_VAL_STR(%s)", strZ(bldCfgRenderEnumStr(scalar)));
|
||||
@@ -513,8 +513,9 @@ bldCfgRenderAllowList(const List *const allowList, const String *const optType)
|
||||
for (unsigned int allowIdx = 0; allowIdx < lstSize(allowList); allowIdx++)
|
||||
{
|
||||
const BldCfgOptionValue *const allow = lstGet(allowList, allowIdx);
|
||||
const String *const value = strEq(optType, OPT_TYPE_STRING_STR) ? strNewFmt("\"%s\"", strZ(allow->value)) : allow->value;
|
||||
|
||||
strCatFmt(result, " %s,\n", strZ(bldCfgRenderScalar(allow->value, optType)));
|
||||
strCatFmt(result, " %s,\n", strZ(bldCfgRenderScalar(value, optType)));
|
||||
|
||||
if (allow->condition != NULL)
|
||||
{
|
||||
@@ -699,6 +700,14 @@ bldCfgRenderValueRender(
|
||||
strNewFmt(
|
||||
"PARSE_RULE_U32_%zu(parseRuleVal%s##value)", bldCfgRenderVar128Size(strLstSize(ruleValList) - 1), abbr))));
|
||||
|
||||
// Add value macro for StringId
|
||||
if (strEq(optType, OPT_TYPE_STRING_STR))
|
||||
{
|
||||
strCatFmt(
|
||||
result, "%s\n",
|
||||
strZ(bldDefineRender(STRDEF("PARSE_RULE_VAL_STRID(value)"), STRDEF("PARSE_RULE_VAL_STR(QT_##value##_QT)"))));
|
||||
}
|
||||
|
||||
// Render values
|
||||
strCatFmt(
|
||||
result,
|
||||
@@ -715,8 +724,6 @@ bldCfgRenderValueRender(
|
||||
|
||||
if (strEq(optType, OPT_TYPE_STRING_STR))
|
||||
strCatFmt(resultVal, " PARSE_RULE_STRPUB(%s),", strZ(strLstGet(ruleValList, ruleValIdx)));
|
||||
else if (strEq(optType, OPT_TYPE_STRING_ID_STR))
|
||||
strCatFmt(resultVal, " %s,", strZ(bldStrId(strZ(strLstGet(ruleValList, ruleValIdx)))));
|
||||
else if (strEq(optType, OPT_TYPE_INTEGER_STR))
|
||||
strCatFmt(resultVal, " %s,", strZ(strTrim(strLstGet(ruleValList, ruleValIdx))));
|
||||
else if (strEq(optType, OPT_TYPE_SIZE_STR))
|
||||
@@ -729,8 +736,7 @@ bldCfgRenderValueRender(
|
||||
strCatZ(result, "\n};\n");
|
||||
|
||||
// Render value to string map
|
||||
if (strEq(optType, OPT_TYPE_STRING_ID_STR) || strEq(optType, OPT_TYPE_INTEGER_STR) || strEq(optType, OPT_TYPE_SIZE_STR) ||
|
||||
strEq(optType, OPT_TYPE_TIME_STR))
|
||||
if (strEq(optType, OPT_TYPE_INTEGER_STR) || strEq(optType, OPT_TYPE_SIZE_STR) || strEq(optType, OPT_TYPE_TIME_STR))
|
||||
{
|
||||
strCatFmt(
|
||||
result,
|
||||
@@ -1399,9 +1405,6 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg, co
|
||||
strCat(
|
||||
configVal,
|
||||
bldCfgRenderValueRender(OPT_TYPE_STRING_STR, ruleValMap, label, "StringPubConst", "String", "Str", "STR", "val/str"));
|
||||
strCat(
|
||||
configVal,
|
||||
bldCfgRenderValueRender(OPT_TYPE_STRING_ID_STR, ruleValMap, label, "StringId", "StringId", "StrId", "STRID", "val/strid"));
|
||||
strCat(configVal, bldCfgRenderValueRender(OPT_TYPE_INTEGER_STR, ruleValMap, label, "int", "Int", "Int", "INT", "val/int"));
|
||||
strCat(configVal, bldCfgRenderValueRender(OPT_TYPE_SIZE_STR, ruleValMap, label, "int64_t", "Size", "Size", "SIZE", "val/size"));
|
||||
strCat(
|
||||
|
||||
+243
-445
File diff suppressed because it is too large
Load Diff
+5
-12
@@ -855,17 +855,9 @@ cfgParseOptionValueStr(const ConfigOptionType type, unsigned int valueIdx)
|
||||
valueIdx = parseRuleValueTimeStrMap[valueIdx];
|
||||
break;
|
||||
|
||||
case cfgOptTypePath:
|
||||
case cfgOptTypeString:
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
ASSERT(type == cfgOptTypeStringId);
|
||||
|
||||
valueIdx = parseRuleValueStrIdStrMap[valueIdx];
|
||||
ASSERT(type == cfgOptTypePath || type == cfgOptTypeString || type == cfgOptTypeStringId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RETURN_CONST(STRING, (const String *)&parseRuleValueStr[valueIdx]);
|
||||
@@ -944,7 +936,7 @@ cfgParseOptionValuePack(PackRead *const ruleData, const ConfigOptionType type, C
|
||||
{
|
||||
ASSERT(type == cfgOptTypeStringId);
|
||||
|
||||
value->stringId = parseRuleValueStrId[valueIdx];
|
||||
value->stringId = strIdFromZ(strZ(cfgParseOptionValueStr(type, valueIdx)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1315,7 +1307,7 @@ cfgParseOptionalFilterDepend(
|
||||
ASSERT(cfgParseOptionDataType(result.dependId) == cfgOptDataTypeStringId);
|
||||
result.matchValue = pckReadU32P(filter);
|
||||
|
||||
if (parseRuleValueStrId[result.matchValue] == dependValue->value.stringId)
|
||||
if (strEq((const String *)&parseRuleValueStr[result.matchValue], dependValue->display))
|
||||
result.valid = true;
|
||||
|
||||
break;
|
||||
@@ -2674,7 +2666,8 @@ cfgParse(const Storage *const storage, const unsigned int argListSize, const cha
|
||||
switch (ruleOption->type)
|
||||
{
|
||||
case cfgOptTypeStringId:
|
||||
allowListFound = parseRuleValueStrId[valueIdx] == configOptionValue->value.stringId;
|
||||
allowListFound = strEq(
|
||||
(const String *)&parseRuleValueStr[valueIdx], configOptionValue->display);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -653,6 +653,7 @@ testRun(void)
|
||||
"Rule Strings\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PARSE_RULE_VAL_STR(value) PARSE_RULE_U32_1(parseRuleValStr##value)\n"
|
||||
"#define PARSE_RULE_VAL_STRID(value) PARSE_RULE_VAL_STR(QT_##value##_QT)\n"
|
||||
"\n"
|
||||
"static const StringPubConst parseRuleValueStr[] =\n"
|
||||
"{\n"
|
||||
@@ -715,50 +716,6 @@ testRun(void)
|
||||
"} ParseRuleValueStr;\n"
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"Rule StringIds\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PARSE_RULE_VAL_STRID(value) PARSE_RULE_U32_1(parseRuleValStrId##value)\n"
|
||||
"\n"
|
||||
"static const StringId parseRuleValueStrId[] =\n"
|
||||
"{\n"
|
||||
" STRID5(\"check\", 0xb195030),\n"
|
||||
" STRID6(\"debug1\", 0x7475421441),\n"
|
||||
" STRID5(\"error\", 0x127ca450),\n"
|
||||
" STRID5(\"gz\", 0x3470),\n"
|
||||
" STRID5(\"info\", 0x799c90),\n"
|
||||
" STRID5(\"n\", 0xe0),\n"
|
||||
" STRID5(\"off\", 0x18cf0),\n"
|
||||
" STRID5(\"warn\", 0x748370),\n"
|
||||
" STRID5(\"y\", 0x190),\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"static const uint8_t parseRuleValueStrIdStrMap[] =\n"
|
||||
"{\n"
|
||||
" parseRuleValStrQT_check_QT,\n"
|
||||
" parseRuleValStrQT_debug1_QT,\n"
|
||||
" parseRuleValStrQT_error_QT,\n"
|
||||
" parseRuleValStrQT_gz_QT,\n"
|
||||
" parseRuleValStrQT_info_QT,\n"
|
||||
" parseRuleValStrQT_n_QT,\n"
|
||||
" parseRuleValStrQT_off_QT,\n"
|
||||
" parseRuleValStrQT_warn_QT,\n"
|
||||
" parseRuleValStrQT_y_QT,\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"typedef enum\n"
|
||||
"{\n"
|
||||
" parseRuleValStrIdCheck,\n"
|
||||
" parseRuleValStrIdDebug1,\n"
|
||||
" parseRuleValStrIdError,\n"
|
||||
" parseRuleValStrIdGz,\n"
|
||||
" parseRuleValStrIdInfo,\n"
|
||||
" parseRuleValStrIdN,\n"
|
||||
" parseRuleValStrIdOff,\n"
|
||||
" parseRuleValStrIdWarn,\n"
|
||||
" parseRuleValStrIdY,\n"
|
||||
"} ParseRuleValueStrId;\n"
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"Rule Ints\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PARSE_RULE_VAL_INT(value) PARSE_RULE_U32_1(parseRuleValInt##value)\n"
|
||||
@@ -1031,14 +988,14 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_LIST\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(N),\n"
|
||||
" PARSE_RULE_VAL_STRID(Check),\n"
|
||||
" PARSE_RULE_VAL_STRID(Y),\n"
|
||||
" PARSE_RULE_VAL_STRID(n),\n"
|
||||
" PARSE_RULE_VAL_STRID(check),\n"
|
||||
" PARSE_RULE_VAL_STRID(y),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(N),\n"
|
||||
" PARSE_RULE_VAL_STRID(n),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
@@ -1177,10 +1134,10 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_RANGE_MAP\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(bz2),\n"
|
||||
" PARSE_RULE_VAL_INT(1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" PARSE_RULE_VAL_INT(DS_1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" ),\n"
|
||||
@@ -1190,9 +1147,9 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT_MAP\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(bz2),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" PARSE_RULE_VAL_INT(6),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
@@ -1204,18 +1161,18 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_DEPEND_DEFAULT(PARSE_RULE_VAL_INT(0)),\n"
|
||||
" PARSE_RULE_VAL_OPT(CompressType),\n"
|
||||
" PARSE_RULE_VAL_STRID(Bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_RANGE\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_RANGE_MAP\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(bz2),\n"
|
||||
" PARSE_RULE_VAL_INT(1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" PARSE_RULE_VAL_INT(DS_1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" ),\n"
|
||||
@@ -1225,9 +1182,9 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT_MAP\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(bz2),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" PARSE_RULE_VAL_INT(6),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
@@ -1286,10 +1243,10 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_RANGE_MAP\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(bz2),\n"
|
||||
" PARSE_RULE_VAL_INT(1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" PARSE_RULE_VAL_INT(DS_1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" ),\n"
|
||||
@@ -1301,18 +1258,18 @@ testRun(void)
|
||||
" PARSE_RULE_OPTIONAL_DEPEND\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_OPT(CompressType),\n"
|
||||
" PARSE_RULE_VAL_STRID(None),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(none),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_RANGE\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_RANGE_MAP\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Bz2),\n"
|
||||
" PARSE_RULE_VAL_STRID(bz2),\n"
|
||||
" PARSE_RULE_VAL_INT(1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" PARSE_RULE_VAL_INT(DS_1),\n"
|
||||
" PARSE_RULE_VAL_INT(9),\n"
|
||||
" ),\n"
|
||||
@@ -1345,7 +1302,7 @@ testRun(void)
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_LIST\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Gz),\n"
|
||||
" PARSE_RULE_VAL_STRID(gz),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
@@ -1375,9 +1332,9 @@ testRun(void)
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_LIST\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STR(none),\n"
|
||||
" PARSE_RULE_VAL_STR(bz2),\n"
|
||||
" PARSE_RULE_VAL_STR(gz),\n"
|
||||
" PARSE_RULE_VAL_STR(QT_none_QT),\n"
|
||||
" PARSE_RULE_VAL_STR(QT_bz2_QT),\n"
|
||||
" PARSE_RULE_VAL_STR(QT_gz_QT),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT\n"
|
||||
@@ -1390,9 +1347,9 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_LIST\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STR(none),\n"
|
||||
" PARSE_RULE_VAL_STR(bz2),\n"
|
||||
" PARSE_RULE_VAL_STR(gz),\n"
|
||||
" PARSE_RULE_VAL_STR(QT_none_QT),\n"
|
||||
" PARSE_RULE_VAL_STR(QT_bz2_QT),\n"
|
||||
" PARSE_RULE_VAL_STR(QT_gz_QT),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT\n"
|
||||
@@ -1522,15 +1479,15 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_LIST\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Off),\n"
|
||||
" PARSE_RULE_VAL_STRID(Error),\n"
|
||||
" PARSE_RULE_VAL_STRID(Warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(Debug1),\n"
|
||||
" PARSE_RULE_VAL_STRID(off),\n"
|
||||
" PARSE_RULE_VAL_STRID(error),\n"
|
||||
" PARSE_RULE_VAL_STRID(warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(debug1),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(warn),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
@@ -1583,18 +1540,18 @@ testRun(void)
|
||||
" PARSE_RULE_OPTIONAL_DEPEND\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_OPT(LogLevelConsole),\n"
|
||||
" PARSE_RULE_VAL_STRID(Warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(warn),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_LIST\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Off),\n"
|
||||
" PARSE_RULE_VAL_STRID(Warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(off),\n"
|
||||
" PARSE_RULE_VAL_STRID(warn),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(warn),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_NOT_REQUIRED(),\n"
|
||||
@@ -1604,15 +1561,15 @@ testRun(void)
|
||||
" (\n"
|
||||
" PARSE_RULE_OPTIONAL_ALLOW_LIST\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Off),\n"
|
||||
" PARSE_RULE_VAL_STRID(Error),\n"
|
||||
" PARSE_RULE_VAL_STRID(Warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(Debug1),\n"
|
||||
" PARSE_RULE_VAL_STRID(off),\n"
|
||||
" PARSE_RULE_VAL_STRID(error),\n"
|
||||
" PARSE_RULE_VAL_STRID(warn),\n"
|
||||
" PARSE_RULE_VAL_STRID(debug1),\n"
|
||||
" ),\n"
|
||||
"\n"
|
||||
" PARSE_RULE_OPTIONAL_DEFAULT\n"
|
||||
" (\n"
|
||||
" PARSE_RULE_VAL_STRID(Info),\n"
|
||||
" PARSE_RULE_VAL_STRID(info),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
" ),\n"
|
||||
|
||||
Reference in New Issue
Block a user