tazel
A build system for C, C++, Objective-C, Objective-C++ and Zig, with C# project files.
Clonegit clone https://git.progmasoft.com/tazel
Decode an OutputFile with an if chain
- Commit
83770de51d5650703ee4c5be0294834af885afed- Author
- Leitwolf11 ·
- Parents
36f96c1440ab
Changes
src/Progmasoft.Tazel/Cache/ActionResultMessage.cs | 30 +++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Progmasoft.Tazel/Cache/ActionResultMessage.cs b/src/Progmasoft.Tazel/Cache/ActionResultMessage.cs index 40a8c33..4ddcde5 100644 --- a/src/Progmasoft.Tazel/Cache/ActionResultMessage.cs +++ b/src/Progmasoft.Tazel/Cache/ActionResultMessage.cs @@ -82,21 +82,25 @@ internal static class ActionResultMessage string? path = null, hash = null; long size = -1; var executable = false; - foreach (var field in Fields(bytes) ?? [new Field(0, -1, 0, null)]) + if (Fields(bytes) is not { } fields) + { + return null; + } + + // Fields Tazel does not read are passed over. + foreach (var field in fields) { - switch (field) + if (field is { Number: 1, Wire: WireLength }) { - case { Number: 1, Wire: WireLength }: - path = Encoding.UTF8.GetString(field.Body!); - break; - case { Number: 2, Wire: WireLength }: - (hash, size) = DecodeDigest(field.Body!); - break; - case { Number: 4, Wire: WireVarint }: - executable = field.Value != 0; - break; - case { Wire: -1 }: - return null; + path = Encoding.UTF8.GetString(field.Body!); + } + else if (field is { Number: 2, Wire: WireLength }) + { + (hash, size) = DecodeDigest(field.Body!); + } + else if (field is { Number: 4, Wire: WireVarint }) + { + executable = field.Value != 0; } }