Don't copy params
This commit is contained in:
@@ -40,10 +40,10 @@ void Request::SetBody(const std::string_view& body) {
|
||||
body_ = body;
|
||||
}
|
||||
|
||||
const std::string& Request::GetParam(const std::string& key) {
|
||||
const std::string_view& Request::GetParam(const std::string& key) {
|
||||
auto iter = params_.find(key);
|
||||
if (iter == params_.end()) {
|
||||
static const std::string none;
|
||||
static const std::string_view none;
|
||||
return none;
|
||||
}
|
||||
return iter->second;
|
||||
|
||||
@@ -21,7 +21,7 @@ class Request {
|
||||
void AddParam(const std::string_view& key, const std::string_view& value);
|
||||
void SetBody(const std::string_view& in);
|
||||
|
||||
const std::string& GetParam(const std::string& key);
|
||||
const std::string_view& GetParam(const std::string& key);
|
||||
const std::string_view& GetBody();
|
||||
|
||||
void WriteHeader(const std::string_view& name, const std::string_view& value);
|
||||
@@ -36,7 +36,7 @@ class Request {
|
||||
Connection *conn_;
|
||||
uint16_t request_id_ = 0;
|
||||
|
||||
std::unordered_map<std::string, std::string> params_;
|
||||
std::unordered_map<std::string_view, std::string_view> params_;
|
||||
std::string_view body_;
|
||||
|
||||
firebuf::Buffer out_buf_;
|
||||
|
||||
Reference in New Issue
Block a user