Remove the ill-considered StringRef::numberOfCharacters

It never counted characters, only codepoints. If you think these
are interchangeable, you should not touch non-ascii text.
This commit is contained in:
Martin Hořeňovský 2019-09-07 20:13:22 +02:00
parent f2c2711bdc
commit fe967b1f41
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
9 changed files with 6 additions and 95 deletions

View file

@ -17,12 +17,6 @@
#include <cstring>
#include <cstdint>
namespace {
const uint32_t byte_2_lead = 0xC0;
const uint32_t byte_3_lead = 0xE0;
const uint32_t byte_4_lead = 0xF0;
}
namespace Catch {
StringRef::StringRef( char const* rawChars ) noexcept
: StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )
@ -82,22 +76,6 @@ namespace Catch {
return m_start[index];
}
auto StringRef::numberOfCharacters() const noexcept -> size_type {
size_type noChars = m_size;
// Make adjustments for uft encodings
for( size_type i=0; i < m_size; ++i ) {
char c = m_start[i];
if( ( c & byte_2_lead ) == byte_2_lead ) {
noChars--;
if (( c & byte_3_lead ) == byte_3_lead )
noChars--;
if( ( c & byte_4_lead ) == byte_4_lead )
noChars--;
}
}
return noChars;
}
auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string {
std::string str;
str.reserve( lhs.size() + rhs.size() );