Skip to content

Commit 335ff07

Browse files
committed
use find_first_of
1 parent 2edfc17 commit 335ff07

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

clickhouse/base/wire_format.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "../exceptions.h"
88

99
#include <stdexcept>
10+
#include <algorithm>
1011

1112
namespace {
1213
constexpr int MAX_VARINT_BYTES = 10;
@@ -100,16 +101,11 @@ bool WireFormat::SkipString(InputStream& input) {
100101
return false;
101102
}
102103

103-
inline const char* find_quoted_chars(const char* start, const char* end) {
104-
static const char quoted_chars[] = {'\0', '\b', '\t', '\n', '\'', '\\'};
105-
while (start < end) {
106-
char c = *start;
107-
for (unsigned i = 0; i < sizeof(quoted_chars); i++) {
108-
if (quoted_chars[i] == c) return start;
109-
}
110-
start++;
111-
}
112-
return nullptr;
104+
inline const char* find_quoted_chars(const char* start, const char* end)
105+
{
106+
static constexpr std::array quoted_chars {'\0', '\b', '\t', '\n', '\'', '\\'};
107+
const auto first = std::find_first_of(start, end, quoted_chars.begin(), quoted_chars.end());
108+
return (first == end) ? nullptr : first;
113109
}
114110

115111
void WireFormat::WriteQuotedString(OutputStream& output, std::string_view value) {

0 commit comments

Comments
 (0)