libeuropa/io: Clean up ReadPString()

While it's moot since we don't read in any hot paths, std::istream already has `read(chars, len)`, which means we don't need to reinvent it poorly. It's cleaner code as well.
This commit is contained in:
Lily Tsuru 2025-01-16 02:14:26 -05:00
parent 361cd12437
commit e7a9412479

View file

@ -54,17 +54,16 @@ namespace europa::io::impl {
std::uint32_t length = static_cast<std::uint32_t>(is.get()); std::uint32_t length = static_cast<std::uint32_t>(is.get());
if(length == 0) { if(length == 0) {
// TODO: is this even possible/valid?
static_cast<void>(is.get()); static_cast<void>(is.get());
return ""; return "";
} }
// Read the string.
s.resize(length - 1); s.resize(length - 1);
is.read(&s[0], length-1);
// Read the string
for(std::uint32_t i = 0; i < length - 1; ++i) {
s[i] = static_cast<char>(is.get());
}
static_cast<void>(is.get()); static_cast<void>(is.get());
return s; return s;
} }