Timur Tabi
2025-Nov-18 01:06 UTC
[PATCH 03/11] gpu: nova-core: support header parsing on Turing/GA100
On Mon, 2025-11-17 at 20:04 -0500, Joel Fernandes wrote:> I don't care about the if/else as much as I care about the opportunity to > just specify FalconLoadTarget once instead twice. I think the match here is cleaner for this > snippet, but I am Ok with the if/else as well. > > Something like: > ?? imem_sec_load_target: FalconLoadTarget { > ?????? src_start: if chipset > Chipset::GA100? { > ????????? app0.offset > ????? } else { > ?????????? load_hdr.os_code_size > ????? }, > > That would be one more line of code, but pretty much the same.Interesting. I would have thought that duplicating the if-statement is the higher offense.
John Hubbard
2025-Nov-18 01:15 UTC
[PATCH 03/11] gpu: nova-core: support header parsing on Turing/GA100
On 11/17/25 5:06 PM, Timur Tabi wrote:> On Mon, 2025-11-17 at 20:04 -0500, Joel Fernandes wrote: >> I don't care about the if/else as much as I care about the opportunity to >> just specify FalconLoadTarget once instead twice. I think the match here is cleaner for this >> snippet, but I am Ok with the if/else as well. >> >> Something like: >> ?? imem_sec_load_target: FalconLoadTarget { >> ?????? src_start: if chipset > Chipset::GA100? { >> ????????? app0.offset >> ????? } else { >> ?????????? load_hdr.os_code_size >> ????? }, >> >> That would be one more line of code, but pretty much the same. > > Interesting. I would have thought that duplicating the if-statement is the higher offense.I think the use of traits here generally makes this all a little better overall though, don't you think? Traits are easier to read and internalize quickly, and easy to maintain too. They are yet another way to make implicit rules explicit and self-documenting. thanks, -- John Hubbard