aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-07-27 14:52:54 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-07-27 14:52:54 +0000
commit2f7f93b7f075d33cc22fc70966ddf29ed4ef65a7 (patch)
treecd8d4ff827eab8a8fe689d700bd2b77d3b927682 /vespalib
parent1b21aebee4e4158a398a6fbf9bcf61f77ac6df21 (diff)
Reduce number of checks and asserts as proper precondition check with validFirstByte has always been conducted.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/text/utf8.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/text/utf8.h3
2 files changed, 1 insertions, 8 deletions
diff --git a/vespalib/src/vespa/vespalib/text/utf8.cpp b/vespalib/src/vespa/vespalib/text/utf8.cpp
index c950f62985f..3a172bbcc6a 100644
--- a/vespalib/src/vespa/vespalib/text/utf8.cpp
+++ b/vespalib/src/vespa/vespalib/text/utf8.cpp
@@ -29,8 +29,6 @@ uint32_t Utf8Reader::getComplexChar(unsigned char firstbyte, uint32_t fallback)
return fallback;
}
int need = Utf8::numContBytes(firstbyte);
- assert(need > 0);
- assert(need < 4);
if (_pos + need > size()) {
LOG(debug, "incomplete data (first byte %02X, pos=%zu, need=%d, size=%zu) in Utf8Reader data block",
@@ -70,7 +68,6 @@ uint32_t Utf8Reader::getComplexChar(unsigned char firstbyte, uint32_t fallback)
return fallback;
}
}
- assert(need == 3);
unsigned char contbyte1 = (*this)[_pos];
unsigned char contbyte2 = (*this)[_pos+1];
@@ -98,8 +95,6 @@ Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) noe
return fallback;
}
int need = Utf8::numContBytes(firstbyte);
- assert(need > 0);
- assert(need < 4);
if (need == 1) {
if (_p[0] == 0) {
@@ -141,7 +136,6 @@ Utf8ReaderForZTS::getComplexChar(unsigned char firstbyte, uint32_t fallback) noe
return fallback;
}
}
- assert(need == 3);
if (_p[0] == 0 || _p[1] == 0 || _p[2] == 0) {
LOG(debug, "incomplete character (first byte %02X) in Utf8ReaderZTS", firstbyte);
diff --git a/vespalib/src/vespa/vespalib/text/utf8.h b/vespalib/src/vespa/vespalib/text/utf8.h
index 3367bd5b3d2..99e3f8cfe13 100644
--- a/vespalib/src/vespa/vespalib/text/utf8.h
+++ b/vespalib/src/vespa/vespalib/text/utf8.h
@@ -56,8 +56,7 @@ public:
if (c < 0x80) return 0;
if (c > 0xC1 && c < 0xE0) return 1;
if (c > 0xDF && c < 0xF0) return 2;
- if (c > 0xEF && c < 0xF5) return 3;
- return -1;
+ return 3;
}
/**