bigianb / bgda-explorer

Code written to try and figure out the data files used in Baldur's Gate Dark Alliance for the PS2
11 stars 6 forks source link

Code Refactor - Pass 1 #16

Closed BryceBarbara closed 3 years ago

BryceBarbara commented 3 years ago

This is one of the stepping stones on the road to modernizing the codebase. Beyond this, I think the last thing to do before the real work can begin is enable nullable reference types and fix up any issues from it.

Changes

bigianb commented 3 years ago

There's quite a bit of repeated code now- I assume that will be refactored out later and will be made more DRY. I think the span implementation is quite in-efficient but as it's not used in any performance sensitive code that's fine.

BryceBarbara commented 3 years ago

Yeah, repeated code isn't ideal but there are so many lower hanging fruit that I want to address prior to that. The primary goal of this PR was just to get .NET 5 working.

And I agree about the span stuff. Calling ToArray is a terrible practice and it pretty much undoes any performance benefits we might have had. But I still see it as a benefit because it simplifies code since it doesn't start offsets. Later, we can replace Span with some other type that doesn't have performance hits but has the same behavior of making a subset of an array and passing it around without actually duplicating memory.