aboutsummaryrefslogtreecommitdiffstats
path: root/util/string/util.cpp
diff options
context:
space:
mode:
authormelkov <melkov@yandex-team.ru>2022-02-10 16:48:14 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:14 +0300
commit2c532b38e6aeb4fd88531027c7335690fd34c4e5 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /util/string/util.cpp
parent438546c8737d5c1fdeb31157dcf999717d930eec (diff)
downloadydb-2c532b38e6aeb4fd88531027c7335690fd34c4e5.tar.gz
Restoring authorship annotation for <melkov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/string/util.cpp')
-rw-r--r--util/string/util.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/util/string/util.cpp b/util/string/util.cpp
index 41dd7db624..b14f20bf75 100644
--- a/util/string/util.cpp
+++ b/util/string/util.cpp
@@ -10,44 +10,44 @@ int a2i(const TString& s) {
return atoi(s.c_str());
}
-//============================== span =====================================
-
+//============================== span =====================================
+
void str_spn::init(const char* charset, bool extended) {
// chars_table_1 is necessary to avoid some unexpected
// multi-threading issues
- ui8 chars_table_1[256];
- memset(chars_table_1, 0, sizeof(chars_table_1));
- if (extended) {
+ ui8 chars_table_1[256];
+ memset(chars_table_1, 0, sizeof(chars_table_1));
+ if (extended) {
for (const char* cs = charset; *cs; cs++) {
- if (cs[1] == '-' && cs[2] != 0) {
+ if (cs[1] == '-' && cs[2] != 0) {
for (int c = (ui8)*cs; c <= (ui8)cs[2]; c++) {
- chars_table_1[c] = 1;
+ chars_table_1[c] = 1;
}
- cs += 2;
- continue;
- }
- chars_table_1[(ui8)*cs] = 1;
- }
- } else {
+ cs += 2;
+ continue;
+ }
+ chars_table_1[(ui8)*cs] = 1;
+ }
+ } else {
for (; *charset; charset++) {
- chars_table_1[(ui8)*charset] = 1;
+ chars_table_1[(ui8)*charset] = 1;
}
- }
- memcpy(chars_table, chars_table_1, 256);
+ }
+ memcpy(chars_table, chars_table_1, 256);
chars_table_1[0] = 1;
for (int n = 0; n < 256; n++) {
c_chars_table[n] = !chars_table_1[n];
}
-}
-
+}
+
Tr::Tr(const char* from, const char* to) {
for (size_t n = 0; n < 256; n++) {
- Map[n] = (char)n;
+ Map[n] = (char)n;
}
for (; *from && *to; from++, to++) {
- Map[(ui8)*from] = *to;
+ Map[(ui8)*from] = *to;
}
-}
+}
size_t Tr::FindFirstChangePosition(const TString& str) const {
for (auto it = str.begin(); it != str.end(); ++it) {