You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-06-20 01:17:49 +02:00
Improve designated initializers in data arrays.
Designated initializers were being used to initialize the structs but not the arrays. Adding designated initializers makes the code a little clearer. In the packTypeMapData array designated initializers also allow removal of the explicit zero padding and make initialization order unimportant (though it is better to keep them in order to match the enum).
This commit is contained in:
@@ -44,11 +44,13 @@ static const struct CompressHelperLocal
|
||||
IoFilter *(*decompressNew)(bool); // Function to create new decompression filter
|
||||
} compressHelperLocal[] =
|
||||
{
|
||||
[compressTypeNone] =
|
||||
{
|
||||
.typeId = STRID5("none", 0x2b9ee0),
|
||||
.type = STRDEF(COMPRESS_TYPE_NONE),
|
||||
.ext = STRDEF(""),
|
||||
},
|
||||
[compressTypeBz2] =
|
||||
{
|
||||
.typeId = STRID5("bz2", 0x73420),
|
||||
.type = STRDEF(BZ2_EXT),
|
||||
@@ -58,6 +60,7 @@ static const struct CompressHelperLocal
|
||||
.decompressType = BZ2_DECOMPRESS_FILTER_TYPE,
|
||||
.decompressNew = bz2DecompressNew,
|
||||
},
|
||||
[compressTypeGz] =
|
||||
{
|
||||
.typeId = STRID5("gz", 0x3470),
|
||||
.type = STRDEF(GZ_EXT),
|
||||
@@ -67,6 +70,7 @@ static const struct CompressHelperLocal
|
||||
.decompressType = GZ_DECOMPRESS_FILTER_TYPE,
|
||||
.decompressNew = gzDecompressNew,
|
||||
},
|
||||
[compressTypeLz4] =
|
||||
{
|
||||
.typeId = STRID6("lz4", 0x2068c1),
|
||||
.type = STRDEF(LZ4_EXT),
|
||||
@@ -76,6 +80,7 @@ static const struct CompressHelperLocal
|
||||
.decompressType = LZ4_DECOMPRESS_FILTER_TYPE,
|
||||
.decompressNew = lz4DecompressNew,
|
||||
},
|
||||
[compressTypeZst] =
|
||||
{
|
||||
.typeId = STRID5("zst", 0x527a0),
|
||||
.type = STRDEF(ZST_EXT),
|
||||
@@ -87,6 +92,7 @@ static const struct CompressHelperLocal
|
||||
.decompressNew = zstDecompressNew,
|
||||
#endif
|
||||
},
|
||||
[compressTypeXz] =
|
||||
{
|
||||
.typeId = STRID5("xz", 0x3580),
|
||||
.type = STRDEF(XZ_EXT),
|
||||
|
||||
+14
-9
@@ -143,67 +143,72 @@ typedef struct PackTypeMapData
|
||||
static const PackTypeMapData packTypeMapData[] =
|
||||
{
|
||||
// Unknown type map data should not be used
|
||||
{0},
|
||||
[pckTypeMapUnknown] = {0},
|
||||
|
||||
// Types that can be encoded entirely in the tag
|
||||
[pckTypeMapArray] =
|
||||
{
|
||||
.type = pckTypeArray,
|
||||
},
|
||||
[pckTypeMapBool] =
|
||||
{
|
||||
.type = pckTypeBool,
|
||||
.valueSingleBit = true,
|
||||
},
|
||||
[pckTypeMapI32] =
|
||||
{
|
||||
.type = pckTypeI32,
|
||||
.valueMultiBit = true,
|
||||
},
|
||||
[pckTypeMapI64] =
|
||||
{
|
||||
.type = pckTypeI64,
|
||||
.valueMultiBit = true,
|
||||
},
|
||||
[pckTypeMapObj] =
|
||||
{
|
||||
.type = pckTypeObj,
|
||||
},
|
||||
// Placeholders for unused type that can be encoded entirely in the tag
|
||||
{0},
|
||||
[pckTypeMapStr] =
|
||||
{
|
||||
.type = pckTypeStr,
|
||||
.valueSingleBit = true,
|
||||
.size = true,
|
||||
},
|
||||
[pckTypeMapU32] =
|
||||
{
|
||||
.type = pckTypeU32,
|
||||
.valueMultiBit = true,
|
||||
},
|
||||
[pckTypeMapU64] =
|
||||
{
|
||||
.type = pckTypeU64,
|
||||
.valueMultiBit = true,
|
||||
},
|
||||
[pckTypeMapStrId] =
|
||||
{
|
||||
.type = pckTypeStrId,
|
||||
.valueMultiBit = true,
|
||||
},
|
||||
|
||||
// Placeholders for unused types that can be encoded entirely in the tag
|
||||
{0},
|
||||
{0},
|
||||
{0},
|
||||
{0},
|
||||
|
||||
// Types that require an extra byte to encode
|
||||
[pckTypeMapTime] =
|
||||
{
|
||||
.type = pckTypeTime,
|
||||
.valueMultiBit = true,
|
||||
},
|
||||
[pckTypeMapBin] =
|
||||
{
|
||||
.type = pckTypeBin,
|
||||
.valueSingleBit = true,
|
||||
.size = true,
|
||||
},
|
||||
[pckTypeMapPack] =
|
||||
{
|
||||
.type = pckTypePack,
|
||||
.size = true,
|
||||
},
|
||||
[pckTypeMapMode] =
|
||||
{
|
||||
.type = pckTypeMode,
|
||||
.valueMultiBit = true,
|
||||
|
||||
Reference in New Issue
Block a user