Skip to content

Commit e1b578a

Browse files
committed
constexpr instead of local static in TelegramParser::try_extract_json_value_str
1 parent a4c90dd commit e1b578a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

vpr/src/server/convertutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ std::string get_truncated_middle_str(const std::string& src, std::size_t num) {
5353
if (num < minimal_string_size_to_truncate) {
5454
num = minimal_string_size_to_truncate;
5555
}
56-
constexpr char middle_place_holder[] = "...";
56+
constexpr const char middle_place_holder[] = "...";
5757
const std::size_t src_size = src.size();
5858
if (src_size > num) {
5959
int prefix_num = num / 2;

vpr/src/server/telegramparser.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
#include "convertutils.h"
55
#include "commconstants.h"
66

7+
#include <cstring>
8+
79
namespace comm {
810

911
std::optional<std::string> TelegramParser::try_extract_json_value_str(const std::string& json_string, const std::string& key) {
10-
static const std::string end_key_pattern{"\":\""};
12+
constexpr const char end_key_pattern[] = {"\":\""};
1113

1214
// Find the position of the key
1315
size_t key_pos = json_string.find('\"' + key + end_key_pattern);
@@ -18,7 +20,7 @@ std::optional<std::string> TelegramParser::try_extract_json_value_str(const std:
1820
}
1921

2022
// Find the position of the value after the key
21-
size_t value_pos_start = json_string.find('\"', key_pos + key.length() + end_key_pattern.size());
23+
size_t value_pos_start = json_string.find('\"', key_pos + key.length() + std::strlen(end_key_pattern));
2224

2325
if (value_pos_start == std::string::npos) {
2426
// Value not found

0 commit comments

Comments
 (0)