Skip to content

Commit bdb7c0d

Browse files
RovicnowYoyipopoaichuiniu
authored andcommitted
[Optimize]Reduce unnecessary copies
Optimize code by changing `std::string` to `const std::string&` for `url` to avoid unnecessary copies and improve performance.
1 parent ca213e5 commit bdb7c0d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

debug_router/native/core/util.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ bool CheckHeaderFourthByte(const char *header, uint32_t payload_size_int) {
5656
return true;
5757
}
5858

59-
std::string decodeURIComponent(std::string url) {
59+
std::string decodeURIComponent(const std::string &url) {
6060
int flag = 0;
6161
int code = 0;
6262
std::stringstream result_url_;
63-
for (char c : url) {
63+
for (const char &c : url) {
6464
if ((flag == 0) && (c == '%')) {
6565
flag = 1;
6666
continue;

debug_router/native/core/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool CheckHeaderFourthByte(const char *header, uint32_t payload_size_int);
3232
bool CheckHeaderThreeBytes(const char *header);
3333

3434
// decode url
35-
std::string decodeURIComponent(std::string url);
35+
std::string decodeURIComponent(const std::string &url);
3636

3737
} // namespace util
3838
} // namespace debugrouter

0 commit comments

Comments
 (0)