From a19421840b8de191d988d8b559ee3689e2e2aa0e Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Thu, 8 Jan 2015 10:59:51 -0800 Subject: [PATCH] Mini-refactoring prompted by https://phabricator.fb.com/D1770460 Summary: I got obliged into this one :o). Test Plan: runtests Reviewed By: meyering@fb.com Subscribers: njormrod, folly-diffs@ FB internal diff: D1772328 Signature: t1:1772328:1420744114:2b81e46d77800d247293cb667bbef86e9d6d4755 --- folly/FBString.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/folly/FBString.h b/folly/FBString.h index e3f86b29..b866b901 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -2322,17 +2322,16 @@ std::basic_istream< n = str.max_size(); } str.erase(); - auto got = is.rdbuf()->sgetc(); - for (; extracted != size_t(n) && got != T::eof() && - !isspace(got); ++extracted) { - // Whew. We get to store this guy + for (auto got = is.rdbuf()->sgetc(); extracted != size_t(n); ++extracted) { + if (got == T::eof()) { + err |= __ios_base::eofbit; + is.width(0); + break; + } + if (isspace(got)) break; str.push_back(got); got = is.rdbuf()->snextc(); } - if (got == T::eof()) { - err |= __ios_base::eofbit; - is.width(0); - } } if (!extracted) { err |= __ios_base::failbit; -- 2.34.1