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:
parent
361cd12437
commit
e7a9412479
1 changed files with 4 additions and 5 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue