if (bla == pkgsomething) { stuff; s = 1; } else if (!s && bla == pkgsomething2) { stuff; s = 1; } else if (!s && bla == pkgsomething3) { stuff; s = 1; }
#The original code was #if (bla == pkgsomething) { # stuff; # s = 1; #}
No I do not think you should "risk" a for loop for 3 unchanging elements.
Name:
Anonymous2025-03-09 1:03
I know you trans fucking faggots and feminist cunts will have a problem with that; But you faggots also use switch statements for non-sequential non-intergers.
Name:
Anonymous2025-03-09 1:07
#Anime style would also work fine: if (bla == pkgsomething) { stuff; s = 1; }
if (!s && bla == pkgsomething2) { stuff; s = 1; }
if (!s && bla == pkgsomething3) { stuff; s = 1; }
That's cleaner, as it doesn't suggest that s is unreachable (though s was defined somewhere above this bloc level)
#BUT NOO U HAVE TO HAVE AN IF ELSIF OR YOU ARE YANDERECHAN!
s is set if a fake package is used, and that code will work on all platforms and compilers. While .. the else if might be optimized away and have unknown compiler specific implementations.
Name:
Anonymous2025-03-09 1:13
on some compilers and some optimization levels the s might not be seen as changed by the same-level bloc.
Was changed to: for ( int i = 0; pak_ext_list[i] != NULL ; i++ ) { const char* cur_ext = pak_ext_list[i]; if ( strcasecmp( ext, cur_ext ) == 0 ) { is_pak = TRUE; } cur_ext = g_strconcat(cur_ext, pakdir_suf, NULL); if ( strcasecmp( ext, cur_ext ) == 0 ) { is_pak = TRUE; }
Name:
Anonymous2025-03-09 1:17
(note I see they are not following ISOC90)
Name:
Anonymous2025-03-09 1:26
const char* pak_ext = ".pk3"; const char* pak2_ext = ".dvks"; const char* pak3_ext = ".pk77"; I'd rather do something like this, const char* cur_ext = pak_ext; if ( strcasecmp( ext, cur_ext ) == 0 ) { is_pak = TRUE; }
cur_ext = g_strconcat(cur_ext, pakdir_suf, NULL); if ( strcasecmp( ext, cur_ext ) == 0 ) { is_pak = TRUE; } //Note: since cur_ext was changed even though it's a const, //This sets the pattern
//Other additional package "formats" for no particular reason if (!is_pak) { cur_ext = pak2_ext; if ( strcasecmp( ext, cur_ext ) == 0 ) { is_pak = TRUE; }
Yes it uses "more code" and "boilerplate" But it doesn't run a for loop for almost no reason for just 2 more extension "types" Which are all zip files anyway.
It's not like these are added frequently. Nor is this a dynamic list of supported formats? So why not set it in stone.
Why risk a for loop running away for no fucking reason? If the counter bit is changed in ram you have a runaway
Name:
Anonymous2025-03-09 9:41
Since almost all will be pk3 and some pk3dir add a check around the other pack code block totally to check if we allready are a pak this will almost always be true, thus skipping the seldom used code. Only will be run when it's one of the new weird gay paks