Date: 2023-11-01 10:39 pm (UTC)
torkell: (Default)
From: [personal profile] torkell
The conclusion at code review was that it's the worst way of doing it except for all the other ways we could think of 😅.

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!
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

December 2025

S M T W T F S
  1 2 3 4 5 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 24th, 2025 04:33 pm
Powered by Dreamwidth Studios