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.
|
/// Convenience function to return std::string. The stream buffer is consumed.
|
||||||
std::string string() noexcept {
|
std::string string() noexcept {
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
std::string str;
|
||||||
ss << rdbuf();
|
auto size = streambuf.size();
|
||||||
return ss.str();
|
str.resize(size);
|
||||||
|
read(&str[0], static_cast<std::streamsize>(size));
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
|
||||||
|
|
@ -163,9 +163,11 @@ namespace SimpleWeb {
|
||||||
/// Convenience function to return std::string. The stream buffer is consumed.
|
/// Convenience function to return std::string. The stream buffer is consumed.
|
||||||
std::string string() noexcept {
|
std::string string() noexcept {
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
std::string str;
|
||||||
ss << rdbuf();
|
auto size = streambuf.size();
|
||||||
return ss.str();
|
str.resize(size);
|
||||||
|
read(&str[0], static_cast<std::streamsize>(size));
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue