libretro / swanstation

GNU General Public License v3.0
93 stars 21 forks source link

There's Windows code in the Unix code #115

Open guijan opened 1 week ago

guijan commented 1 week ago

In this large block of code that compromises a single #if defined(_WIN32) #else #endif conditional: https://github.com/libretro/swanstation/blob/7a27436548128c00e70b08dde63c52118e2a6228/src/common/byte_stream.cpp#L692-L1073 In the #else branch: https://github.com/libretro/swanstation/blob/7a27436548128c00e70b08dde63c52118e2a6228/src/common/byte_stream.cpp#L904-L1073 You can see that there are #if defined(_WIN32) checks which will never be true: https://github.com/libretro/swanstation/blob/7a27436548128c00e70b08dde63c52118e2a6228/src/common/byte_stream.cpp#L944-L964 https://github.com/libretro/swanstation/blob/7a27436548128c00e70b08dde63c52118e2a6228/src/common/byte_stream.cpp#L992-L994

We have the same situation in the Windows code, with conditional compilation to handle the Unix path separator which will never trigger. It looks like these branches were copypasted from the same code.

The low effort fix would be to simply remove these unused branches, however, the real fix would be to unify the Windows and Unix code because it's almost the same, it appears the Windows code only differs in having some character set conversion to deal with Windows versions without UTF-8 support, the rest of the code shouldn't be inside a preprocessor conditional.

DarthMew commented 1 week ago

Removed the redundant code via: https://github.com/libretro/swanstation/commit/092b8127257d204775fd26c329f0019719b09dea

If you want to simplify the code further, be my guest.