Rearrange characters in whitespace string

The arrangement saves about 1.3 seconds when running the test vectors. It looks like the tab character is dominant, so we profit by listing it first.
pull/186/merge
Jeffrey Walton 2017-05-14 04:09:26 -04:00
parent 2c570e27a0
commit 017f7f61b4
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 7 additions and 8 deletions

View File

@ -712,20 +712,19 @@ bool GetField(std::istream &is, std::string &name, std::string &value)
} }
} }
// Leading, trailing and temp position. The leading position moves right, and // Leading and trailing position. The leading position moves right, and
// trailing position moves left. The sub-string in the middle is the value for // trailing position moves left. The sub-string in the middle is the value
// the name. We leave one space when line continuation is in effect, (and if // for the name. We leave one space when line continuation is in effect.
// present). The value can be an empty string. One Plaintext value is often // The value can be an empty string. One Plaintext value is often empty
// empty for algorithm testing. // for algorithm testing.
std::string::size_type l=0, t=std::string::npos; std::string::size_type l=0, t=std::string::npos;
const std::string whitespace = " \r\n\t\v\f"; const std::string whitespace = "\t \r\n";
l = line.find_first_not_of(whitespace, l); l = line.find_first_not_of(whitespace, l);
if (l == std::string::npos) { l = 0; } if (l == std::string::npos) { l = 0; }
t = line.find('#', l); t = line.find('#', l);
if (t != std::string::npos) { t--; } if (t != std::string::npos) { t--; }
t = line.find_last_not_of(whitespace, t);
t = line.find_last_not_of(whitespace+"\\", t);
if (t != std::string::npos) { t++; } if (t != std::string::npos) { t++; }
CRYPTOPP_ASSERT(t >= l); CRYPTOPP_ASSERT(t >= l);