mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Refactor allow list processing in config/parse module.
Combine StringId and int checking into a single loop. This seems more compact and makes it easier to add code that affects both types (and possibly more types in the future).
This commit is contained in:
parent
48b26bf569
commit
de46276bf6
@ -2351,29 +2351,31 @@ cfgParse(const Storage *const storage, const unsigned int argListSize, const cha
|
||||
PackRead *const allowList = pckReadNewC(optionalRules.allowList, optionalRules.allowListSize);
|
||||
bool allowListFound = false;
|
||||
|
||||
if (parseRuleOption[optionId].type == cfgOptTypeStringId)
|
||||
pckReadNext(allowList);
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (pckReadNext(allowList))
|
||||
// Compare based on option type
|
||||
const unsigned int valueIdx = pckReadU32P(allowList);
|
||||
|
||||
switch (parseRuleOption[optionId].type)
|
||||
{
|
||||
if (parseRuleValueStrId[pckReadU32P(allowList)] == configOptionValue->value.stringId)
|
||||
{
|
||||
allowListFound = true;
|
||||
case cfgOptTypeStringId:
|
||||
allowListFound = parseRuleValueStrId[valueIdx] == configOptionValue->value.stringId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
default:
|
||||
{
|
||||
ASSERT(parseRuleOption[optionId].type == cfgOptTypeSize);
|
||||
|
||||
while (pckReadNext(allowList))
|
||||
{
|
||||
if (parseRuleValueInt[pckReadU32P(allowList)] == configOptionValue->value.integer)
|
||||
{
|
||||
allowListFound = true;
|
||||
allowListFound = parseRuleValueInt[valueIdx] == configOptionValue->value.integer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Stop when value is found or allow list is exhausted
|
||||
if (allowListFound || !pckReadNext(allowList))
|
||||
break;
|
||||
}
|
||||
|
||||
pckReadFree(allowList);
|
||||
|
Loading…
Reference in New Issue
Block a user