Optimized string() functions
This commit is contained in:
parent
5416b2736b
commit
d59b7c234c
2 changed files with 10 additions and 6 deletions
|
|
@ -62,9 +62,11 @@ namespace SimpleWeb {
|
|||
/// Convenience function to return std::string. The stream buffer is consumed.
|
||||
std::string string() noexcept {
|
||||
try {
|
||||
std::stringstream ss;
|
||||
ss << rdbuf();
|
||||
return ss.str();
|
||||
std::string str;
|
||||
auto size = streambuf.size();
|
||||
str.resize(size);
|
||||
read(&str[0], static_cast<std::streamsize>(size));
|
||||
return str;
|
||||
}
|
||||
catch(...) {
|
||||
return std::string();
|
||||
|
|
|
|||
|
|
@ -163,9 +163,11 @@ namespace SimpleWeb {
|
|||
/// Convenience function to return std::string. The stream buffer is consumed.
|
||||
std::string string() noexcept {
|
||||
try {
|
||||
std::stringstream ss;
|
||||
ss << rdbuf();
|
||||
return ss.str();
|
||||
std::string str;
|
||||
auto size = streambuf.size();
|
||||
str.resize(size);
|
||||
read(&str[0], static_cast<std::streamsize>(size));
|
||||
return str;
|
||||
}
|
||||
catch(...) {
|
||||
return std::string();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue