diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2022-05-08 16:09:24 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2022-05-08 16:12:41 +0200 |
commit | 49f9bdeaf9ca1b5b25cc922f768b995444c4c028 (patch) | |
tree | a8a6920d3d8e8e3f7334f548c132ed7b3369ad23 | |
parent | ee1314f8561cd7ea3426caa888aae5eb23ab7641 (diff) | |
download | ccache-49f9bdeaf9ca1b5b25cc922f768b995444c4c028.tar.gz |
refactor: Simplify Reader::read_int
std::string::operator[](0) is well-defined for empty strings.
-rw-r--r-- | src/core/Reader.hpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/core/Reader.hpp b/src/core/Reader.hpp index 291c3562..317005ef 100644 --- a/src/core/Reader.hpp +++ b/src/core/Reader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Joel Rosdahl and other contributors +// Copyright (C) 2021-2022 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -72,11 +72,9 @@ inline std::string Reader::read_str(const size_t length) { std::string value(length, 0); - if (length > 0) { - const auto bytes_read = read(&value[0], length); - if (bytes_read != length) { - throw core::Error("Read underflow"); - } + const auto bytes_read = read(&value[0], length); + if (bytes_read != length) { + throw core::Error("Read underflow"); } return value; } |