Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
16a69ee1
Commit
16a69ee1
authored
Nov 25, 2020
by
hyperxor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix several unnecessary copies of objects
parent
166d82dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
include/pistache/router.h
include/pistache/router.h
+1
-1
src/common/http.cc
src/common/http.cc
+3
-3
src/server/router.cc
src/server/router.cc
+4
-5
No files found.
include/pistache/router.h
View file @
16a69ee1
...
...
@@ -282,7 +282,7 @@ public:
std
::
vector
<
TypedParam
>
splat
()
const
;
private:
explicit
Request
(
const
Http
::
Request
&
request
,
explicit
Request
(
Http
::
Request
request
,
std
::
vector
<
TypedParam
>
&&
params
,
std
::
vector
<
TypedParam
>
&&
splats
);
...
...
src/common/http.cc
View file @
16a69ee1
...
...
@@ -924,15 +924,15 @@ void Handler::onInput(const char *buffer, size_t len,
}
auto
state
=
parser
.
parse
();
auto
&
request
=
parser
.
request
;
if
(
state
==
Private
::
State
::
Done
)
{
ResponseWriter
response
(
transport
(),
parser
.
request
,
this
,
peer
);
ResponseWriter
response
(
transport
(),
request
,
this
,
peer
);
#ifdef LIBSTDCPP_SMARTPTR_LOCK_FIXME
parser
.
request
.
associatePeer
(
peer
);
request
.
associatePeer
(
peer
);
#endif
auto
request
=
parser
.
request
;
request
.
copyAddress
(
peer
->
address
());
auto
connection
=
request
.
headers
().
tryGet
<
Header
::
Connection
>
();
...
...
src/server/router.cc
View file @
16a69ee1
...
...
@@ -12,9 +12,9 @@
namespace
Pistache
{
namespace
Rest
{
Request
::
Request
(
const
Http
::
Request
&
request
,
std
::
vector
<
TypedParam
>
&&
params
,
Request
::
Request
(
Http
::
Request
request
,
std
::
vector
<
TypedParam
>
&&
params
,
std
::
vector
<
TypedParam
>
&&
splats
)
:
Http
::
Request
(
request
),
params_
(
std
::
move
(
params
)),
:
Http
::
Request
(
std
::
move
(
request
)
),
params_
(
std
::
move
(
params
)),
splats_
(
std
::
move
(
splats
))
{}
bool
Request
::
hasParam
(
const
std
::
string
&
name
)
const
{
...
...
@@ -303,8 +303,7 @@ RouterHandler::RouterHandler(std::shared_ptr<Rest::Router> router)
void
RouterHandler
::
onRequest
(
const
Http
::
Request
&
req
,
Http
::
ResponseWriter
response
)
{
auto
resp
=
response
.
clone
();
router
->
route
(
req
,
std
::
move
(
resp
));
router
->
route
(
req
,
std
::
move
(
response
));
}
}
// namespace Private
...
...
@@ -422,7 +421,7 @@ Route::Status Router::route(const Http::Request &http_req,
if
(
route
!=
nullptr
)
{
auto
params
=
std
::
get
<
1
>
(
result
);
auto
splats
=
std
::
get
<
2
>
(
result
);
route
->
invokeHandler
(
Request
(
req
,
std
::
move
(
params
),
std
::
move
(
splats
)),
route
->
invokeHandler
(
Request
(
std
::
move
(
req
)
,
std
::
move
(
params
),
std
::
move
(
splats
)),
std
::
move
(
resp
));
return
Route
::
Status
::
Match
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment