Active Entries
- 1: Advent, day 5
- 2: Today's programming silliness
- 3: The highly inaccurate guide to the Eurovision Song Contest 2022 results!
- 4: Bang!
- 5: How not to get people to use a new feature
- 6: Misty creek and eerie fog
- 7: Remember...
- 8: Brexit means arrows?
- 9: boggyb's highly inaccurate guide to Eurovision: Shine a Light 2
- 10: Brighton again
Style Credit
- Style: Neutral Good for Practicality by
Expand Cut Tags
No cut tags
no subject
Date: 2023-11-01 10:39 pm (UTC)It's a chunk of code converting from one struct to another, where there's a half-dozen fields repeated twice, and then that entire block is repeated twice with a few more fields. It should be nested types, and indeed it is in a C# version - but this function is in C where it's all flat structs with awkward bit packing. So the 16-parameter function has pointers to the fields to read from the input struct, pointers to the fields to write in the output struct, and a handful of constants for flags. Then the 39-parameter function takes all that times two, and calls the 16-parameter function twice. Then the top-level code calls that 39-parameter function twice.
It does at least mean it's easy to scan through and see "this is reading part A1, this is reading part A2, etc" and then have the conversion logic in one place. The other way I could think of is copy'n'paste four times and hope I've updated everything!