mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 03:27:44 +00:00
AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
This commit is contained in:
parent
1726c17d0d
commit
6f4c380d95
54 changed files with 387 additions and 377 deletions
|
@ -148,6 +148,12 @@ public:
|
|||
m_buffer[m_offset++] = (u8)(value >> 24);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BufferStream& operator<<(size_t value)
|
||||
{
|
||||
return *this << (u32)value;
|
||||
}
|
||||
|
||||
BufferStream& operator>>(u32& value)
|
||||
{
|
||||
if (m_offset + sizeof(value) > unsigned(m_buffer.size())) {
|
||||
|
@ -200,7 +206,7 @@ public:
|
|||
|
||||
BufferStream& operator<<(const StringView& value)
|
||||
{
|
||||
for (ssize_t i = 0; i < value.length(); ++i)
|
||||
for (size_t i = 0; i < value.length(); ++i)
|
||||
m_buffer[m_offset++] = value[i];
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ String JsonParser::consume_quoted_string()
|
|||
Vector<char, 1024> buffer;
|
||||
|
||||
for (;;) {
|
||||
int peek_index = m_index;
|
||||
size_t peek_index = m_index;
|
||||
char ch = 0;
|
||||
for (;;) {
|
||||
if (peek_index == m_input.length())
|
||||
|
@ -104,7 +104,7 @@ String JsonParser::consume_quoted_string()
|
|||
return String::empty();
|
||||
|
||||
auto& last_string_starting_with_character = m_last_string_starting_with_character[(int)buffer.first()];
|
||||
if (last_string_starting_with_character.length() == buffer.size()) {
|
||||
if (last_string_starting_with_character.length() == (size_t)buffer.size()) {
|
||||
if (!memcmp(last_string_starting_with_character.characters(), buffer.data(), buffer.size()))
|
||||
return last_string_starting_with_character;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ private:
|
|||
void consume_while(C);
|
||||
|
||||
StringView m_input;
|
||||
int m_index { 0 };
|
||||
size_t m_index { 0 };
|
||||
|
||||
String m_last_string_starting_with_character[256];
|
||||
};
|
||||
|
|
|
@ -76,7 +76,7 @@ String String::isolated_copy() const
|
|||
return String(move(*impl));
|
||||
}
|
||||
|
||||
String String::substring(int start, int length) const
|
||||
String String::substring(size_t start, size_t length) const
|
||||
{
|
||||
if (!length)
|
||||
return {};
|
||||
|
@ -86,7 +86,7 @@ String String::substring(int start, int length) const
|
|||
return { characters() + start, length };
|
||||
}
|
||||
|
||||
StringView String::substring_view(int start, int length) const
|
||||
StringView String::substring_view(size_t start, size_t length) const
|
||||
{
|
||||
if (!length)
|
||||
return {};
|
||||
|
@ -101,23 +101,23 @@ Vector<String> String::split(const char separator) const
|
|||
return split_limit(separator, 0);
|
||||
}
|
||||
|
||||
Vector<String> String::split_limit(const char separator, int limit) const
|
||||
Vector<String> String::split_limit(const char separator, size_t limit) const
|
||||
{
|
||||
if (is_empty())
|
||||
return {};
|
||||
|
||||
Vector<String> v;
|
||||
int substart = 0;
|
||||
for (int i = 0; i < length() && (v.size() + 1) != limit; ++i) {
|
||||
size_t substart = 0;
|
||||
for (size_t i = 0; i < length() && ((size_t)v.size() + 1) != limit; ++i) {
|
||||
char ch = characters()[i];
|
||||
if (ch == separator) {
|
||||
int sublen = i - substart;
|
||||
size_t sublen = i - substart;
|
||||
if (sublen != 0)
|
||||
v.append(substring(substart, sublen));
|
||||
substart = i + 1;
|
||||
}
|
||||
}
|
||||
int taillen = length() - substart;
|
||||
size_t taillen = length() - substart;
|
||||
if (taillen != 0)
|
||||
v.append(substring(substart, taillen));
|
||||
if (characters()[length() - 1] == separator)
|
||||
|
@ -131,17 +131,17 @@ Vector<StringView> String::split_view(const char separator, bool keep_empty) con
|
|||
return {};
|
||||
|
||||
Vector<StringView> v;
|
||||
int substart = 0;
|
||||
for (int i = 0; i < length(); ++i) {
|
||||
size_t substart = 0;
|
||||
for (size_t i = 0; i < length(); ++i) {
|
||||
char ch = characters()[i];
|
||||
if (ch == separator) {
|
||||
int sublen = i - substart;
|
||||
size_t sublen = i - substart;
|
||||
if (sublen != 0 || keep_empty)
|
||||
v.append(substring_view(substart, sublen));
|
||||
substart = i + 1;
|
||||
}
|
||||
}
|
||||
int taillen = length() - substart;
|
||||
size_t taillen = length() - substart;
|
||||
if (taillen != 0 || keep_empty)
|
||||
v.append(substring_view(substart, taillen));
|
||||
if (characters()[length() - 1] == separator && keep_empty)
|
||||
|
@ -160,7 +160,7 @@ int String::to_int(bool& ok) const
|
|||
{
|
||||
bool negative = false;
|
||||
int value = 0;
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
|
||||
if (is_empty()) {
|
||||
ok = false;
|
||||
|
@ -187,7 +187,7 @@ int String::to_int(bool& ok) const
|
|||
unsigned String::to_uint(bool& ok) const
|
||||
{
|
||||
unsigned value = 0;
|
||||
for (int i = 0; i < length(); ++i) {
|
||||
for (size_t i = 0; i < length(); ++i) {
|
||||
if (characters()[i] < '0' || characters()[i] > '9') {
|
||||
ok = false;
|
||||
return 0;
|
||||
|
@ -250,7 +250,7 @@ bool String::ends_with(const StringView& str) const
|
|||
return !memcmp(characters() + (length() - str.length()), str.characters_without_null_termination(), str.length());
|
||||
}
|
||||
|
||||
String String::repeated(char ch, int count)
|
||||
String String::repeated(char ch, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
return empty();
|
||||
|
|
14
AK/String.h
14
AK/String.h
|
@ -59,7 +59,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
String(const char* cstring, int length, ShouldChomp shouldChomp = NoChomp)
|
||||
String(const char* cstring, size_t length, ShouldChomp shouldChomp = NoChomp)
|
||||
: m_impl(StringImpl::create(cstring, length, shouldChomp))
|
||||
{
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
CaseSensitive,
|
||||
};
|
||||
|
||||
static String repeated(char, int count);
|
||||
static String repeated(char, size_t count);
|
||||
bool matches(const StringView& pattern, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;
|
||||
|
||||
// FIXME: These should be shared between String and StringView somehow!
|
||||
|
@ -112,18 +112,18 @@ public:
|
|||
|
||||
bool contains(const String&) const;
|
||||
|
||||
Vector<String> split_limit(char separator, int limit) const;
|
||||
Vector<String> split_limit(char separator, size_t limit) const;
|
||||
Vector<String> split(char separator) const;
|
||||
String substring(int start, int length) const;
|
||||
String substring(size_t start, size_t length) const;
|
||||
|
||||
Vector<StringView> split_view(char separator, bool keep_empty = false) const;
|
||||
StringView substring_view(int start, int length) const;
|
||||
StringView substring_view(size_t start, size_t length) const;
|
||||
|
||||
bool is_null() const { return !m_impl; }
|
||||
bool is_empty() const { return length() == 0; }
|
||||
int length() const { return m_impl ? m_impl->length() : 0; }
|
||||
size_t length() const { return m_impl ? m_impl->length() : 0; }
|
||||
const char* characters() const { return m_impl ? m_impl->characters() : nullptr; }
|
||||
char operator[](int i) const
|
||||
char operator[](size_t i) const
|
||||
{
|
||||
ASSERT(m_impl);
|
||||
return (*m_impl)[i];
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
inline void StringBuilder::will_append(int size)
|
||||
inline void StringBuilder::will_append(size_t size)
|
||||
{
|
||||
if ((m_length + size) > m_buffer.size())
|
||||
m_buffer.grow(max((int)16, m_buffer.size() * 2 + size));
|
||||
if ((m_length + size) > (size_t)m_buffer.size())
|
||||
m_buffer.grow(max((size_t)16, (size_t)m_buffer.size() * 2 + size));
|
||||
}
|
||||
|
||||
StringBuilder::StringBuilder(int initial_capacity)
|
||||
StringBuilder::StringBuilder(size_t initial_capacity)
|
||||
{
|
||||
m_buffer.grow(initial_capacity);
|
||||
m_buffer.grow((int)initial_capacity);
|
||||
}
|
||||
|
||||
void StringBuilder::append(const StringView& str)
|
||||
|
@ -25,7 +25,7 @@ void StringBuilder::append(const StringView& str)
|
|||
m_length += str.length();
|
||||
}
|
||||
|
||||
void StringBuilder::append(const char* characters, int length)
|
||||
void StringBuilder::append(const char* characters, size_t length)
|
||||
{
|
||||
if (!length)
|
||||
return;
|
||||
|
|
|
@ -10,12 +10,12 @@ class StringBuilder {
|
|||
public:
|
||||
using OutputType = String;
|
||||
|
||||
explicit StringBuilder(int initial_capacity = 16);
|
||||
explicit StringBuilder(size_t initial_capacity = 16);
|
||||
~StringBuilder() {}
|
||||
|
||||
void append(const StringView&);
|
||||
void append(char);
|
||||
void append(const char*, int);
|
||||
void append(const char*, size_t);
|
||||
void appendf(const char*, ...);
|
||||
void appendvf(const char*, va_list);
|
||||
|
||||
|
@ -27,14 +27,14 @@ public:
|
|||
StringView string_view() const;
|
||||
void clear();
|
||||
|
||||
int length() const { return m_length; }
|
||||
void trim(int count) { m_length -= count; }
|
||||
size_t length() const { return m_length; }
|
||||
void trim(size_t count) { m_length -= count; }
|
||||
|
||||
private:
|
||||
void will_append(int);
|
||||
void will_append(size_t);
|
||||
|
||||
ByteBuffer m_buffer;
|
||||
int m_length { 0 };
|
||||
size_t m_length { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ void dump_all_stringimpls()
|
|||
{
|
||||
unsigned i = 0;
|
||||
for (auto& it : *g_all_live_stringimpls) {
|
||||
dbgprintf("%u: \"%s\"\n", i, (*it).characters());
|
||||
dbgprsize_tf("%u: \"%s\"\n", i, (*it).characters());
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ StringImpl& StringImpl::the_empty_stringimpl()
|
|||
return *s_the_empty_stringimpl;
|
||||
}
|
||||
|
||||
StringImpl::StringImpl(ConstructWithInlineBufferTag, int length)
|
||||
StringImpl::StringImpl(ConstructWithInlineBufferTag, size_t length)
|
||||
: m_length(length)
|
||||
{
|
||||
#ifdef DEBUG_STRINGIMPL
|
||||
|
@ -55,12 +55,12 @@ StringImpl::~StringImpl()
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline int allocation_size_for_stringimpl(int length)
|
||||
static inline size_t allocation_size_for_stringimpl(size_t length)
|
||||
{
|
||||
return sizeof(StringImpl) + (sizeof(char) * length) + sizeof(char);
|
||||
}
|
||||
|
||||
NonnullRefPtr<StringImpl> StringImpl::create_uninitialized(int length, char*& buffer)
|
||||
NonnullRefPtr<StringImpl> StringImpl::create_uninitialized(size_t length, char*& buffer)
|
||||
{
|
||||
ASSERT(length);
|
||||
void* slot = kmalloc(allocation_size_for_stringimpl(length));
|
||||
|
@ -71,7 +71,7 @@ NonnullRefPtr<StringImpl> StringImpl::create_uninitialized(int length, char*& bu
|
|||
return new_stringimpl;
|
||||
}
|
||||
|
||||
RefPtr<StringImpl> StringImpl::create(const char* cstring, int length, ShouldChomp should_chomp)
|
||||
RefPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, ShouldChomp should_chomp)
|
||||
{
|
||||
if (!cstring)
|
||||
return nullptr;
|
||||
|
@ -133,7 +133,7 @@ static inline char to_ascii_uppercase(char c)
|
|||
|
||||
NonnullRefPtr<StringImpl> StringImpl::to_lowercase() const
|
||||
{
|
||||
for (int i = 0; i < m_length; ++i) {
|
||||
for (size_t i = 0; i < m_length; ++i) {
|
||||
if (!is_ascii_lowercase(characters()[i]))
|
||||
goto slow_path;
|
||||
}
|
||||
|
@ -142,14 +142,14 @@ NonnullRefPtr<StringImpl> StringImpl::to_lowercase() const
|
|||
slow_path:
|
||||
char* buffer;
|
||||
auto lowercased = create_uninitialized(m_length, buffer);
|
||||
for (int i = 0; i < m_length; ++i)
|
||||
for (size_t i = 0; i < m_length; ++i)
|
||||
buffer[i] = to_ascii_lowercase(characters()[i]);
|
||||
return lowercased;
|
||||
}
|
||||
|
||||
NonnullRefPtr<StringImpl> StringImpl::to_uppercase() const
|
||||
{
|
||||
for (int i = 0; i < m_length; ++i) {
|
||||
for (size_t i = 0; i < m_length; ++i) {
|
||||
if (!is_ascii_uppercase(characters()[i]))
|
||||
goto slow_path;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ NonnullRefPtr<StringImpl> StringImpl::to_uppercase() const
|
|||
slow_path:
|
||||
char* buffer;
|
||||
auto uppercased = create_uninitialized(m_length, buffer);
|
||||
for (int i = 0; i < m_length; ++i)
|
||||
for (size_t i = 0; i < m_length; ++i)
|
||||
buffer[i] = to_ascii_uppercase(characters()[i]);
|
||||
return uppercased;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ enum ShouldChomp {
|
|||
|
||||
class StringImpl : public RefCounted<StringImpl> {
|
||||
public:
|
||||
static NonnullRefPtr<StringImpl> create_uninitialized(int length, char*& buffer);
|
||||
static NonnullRefPtr<StringImpl> create_uninitialized(size_t length, char*& buffer);
|
||||
static RefPtr<StringImpl> create(const char* cstring, ShouldChomp = NoChomp);
|
||||
static RefPtr<StringImpl> create(const char* cstring, int length, ShouldChomp = NoChomp);
|
||||
static RefPtr<StringImpl> create(const char* cstring, size_t length, ShouldChomp = NoChomp);
|
||||
NonnullRefPtr<StringImpl> to_lowercase() const;
|
||||
NonnullRefPtr<StringImpl> to_uppercase() const;
|
||||
|
||||
|
@ -29,11 +29,11 @@ public:
|
|||
|
||||
~StringImpl();
|
||||
|
||||
int length() const { return m_length; }
|
||||
size_t length() const { return m_length; }
|
||||
const char* characters() const { return &m_inline_buffer[0]; }
|
||||
char operator[](int i) const
|
||||
char operator[](size_t i) const
|
||||
{
|
||||
ASSERT(i >= 0 && i < m_length);
|
||||
ASSERT(i < m_length);
|
||||
return characters()[i];
|
||||
}
|
||||
|
||||
|
@ -56,20 +56,20 @@ private:
|
|||
enum ConstructWithInlineBufferTag {
|
||||
ConstructWithInlineBuffer
|
||||
};
|
||||
StringImpl(ConstructWithInlineBufferTag, int length);
|
||||
StringImpl(ConstructWithInlineBufferTag, size_t length);
|
||||
|
||||
void compute_hash() const;
|
||||
|
||||
int m_length { 0 };
|
||||
size_t m_length { 0 };
|
||||
mutable unsigned m_hash { 0 };
|
||||
mutable bool m_has_hash { false };
|
||||
char m_inline_buffer[0];
|
||||
};
|
||||
|
||||
inline constexpr u32 string_hash(const char* characters, int length)
|
||||
inline constexpr u32 string_hash(const char* characters, size_t length)
|
||||
{
|
||||
u32 hash = 0;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
hash += (u32)characters[i];
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
|
|
|
@ -12,7 +12,7 @@ StringView::StringView(const String& string)
|
|||
|
||||
StringView::StringView(const ByteBuffer& buffer)
|
||||
: m_characters((const char*)buffer.data())
|
||||
, m_length(buffer.size())
|
||||
, m_length((size_t)buffer.size())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -22,17 +22,17 @@ Vector<StringView> StringView::split_view(const char separator, bool keep_empty)
|
|||
return {};
|
||||
|
||||
Vector<StringView> v;
|
||||
ssize_t substart = 0;
|
||||
for (ssize_t i = 0; i < length(); ++i) {
|
||||
size_t substart = 0;
|
||||
for (size_t i = 0; i < length(); ++i) {
|
||||
char ch = characters_without_null_termination()[i];
|
||||
if (ch == separator) {
|
||||
ssize_t sublen = i - substart;
|
||||
size_t sublen = i - substart;
|
||||
if (sublen != 0 || keep_empty)
|
||||
v.append(substring_view(substart, sublen));
|
||||
substart = i + 1;
|
||||
}
|
||||
}
|
||||
ssize_t taillen = length() - substart;
|
||||
size_t taillen = length() - substart;
|
||||
if (taillen != 0 || keep_empty)
|
||||
v.append(substring_view(substart, taillen));
|
||||
if (characters_without_null_termination()[length() - 1] == separator && keep_empty)
|
||||
|
@ -49,10 +49,10 @@ Vector<StringView> StringView::lines(bool consider_cr) const
|
|||
return split_view('\n', true);
|
||||
|
||||
Vector<StringView> v;
|
||||
ssize_t substart = 0;
|
||||
size_t substart = 0;
|
||||
bool last_ch_was_cr = false;
|
||||
bool split_view = false;
|
||||
for (ssize_t i = 0; i < length(); ++i) {
|
||||
for (size_t i = 0; i < length(); ++i) {
|
||||
char ch = characters_without_null_termination()[i];
|
||||
if (ch == '\n') {
|
||||
split_view = true;
|
||||
|
@ -67,13 +67,13 @@ Vector<StringView> StringView::lines(bool consider_cr) const
|
|||
last_ch_was_cr = true;
|
||||
}
|
||||
if (split_view) {
|
||||
ssize_t sublen = i - substart;
|
||||
size_t sublen = i - substart;
|
||||
v.append(substring_view(substart, sublen));
|
||||
substart = i + 1;
|
||||
}
|
||||
split_view = false;
|
||||
}
|
||||
ssize_t taillen = length() - substart;
|
||||
size_t taillen = length() - substart;
|
||||
if (taillen != 0)
|
||||
v.append(substring_view(substart, taillen));
|
||||
return v;
|
||||
|
@ -92,7 +92,7 @@ bool StringView::starts_with(const StringView& str) const
|
|||
return !memcmp(characters_without_null_termination(), str.characters_without_null_termination(), str.length());
|
||||
}
|
||||
|
||||
StringView StringView::substring_view(int start, int length) const
|
||||
StringView StringView::substring_view(size_t start, size_t length) const
|
||||
{
|
||||
if (!length)
|
||||
return {};
|
||||
|
@ -105,7 +105,7 @@ StringView StringView::substring_view_starting_from_substring(const StringView&
|
|||
const char* remaining_characters = substring.characters_without_null_termination();
|
||||
ASSERT(remaining_characters >= m_characters);
|
||||
ASSERT(remaining_characters <= m_characters + m_length);
|
||||
int remaining_length = m_length - (remaining_characters - m_characters);
|
||||
size_t remaining_length = m_length - (remaining_characters - m_characters);
|
||||
return { remaining_characters, remaining_length };
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ StringView StringView::substring_view_starting_after_substring(const StringView&
|
|||
const char* remaining_characters = substring.characters_without_null_termination() + substring.length();
|
||||
ASSERT(remaining_characters >= m_characters);
|
||||
ASSERT(remaining_characters <= m_characters + m_length);
|
||||
int remaining_length = m_length - (remaining_characters - m_characters);
|
||||
size_t remaining_length = m_length - (remaining_characters - m_characters);
|
||||
return { remaining_characters, remaining_length };
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ int StringView::to_int(bool& ok) const
|
|||
{
|
||||
bool negative = false;
|
||||
int value = 0;
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
|
||||
if (is_empty()) {
|
||||
ok = false;
|
||||
|
@ -149,7 +149,7 @@ int StringView::to_int(bool& ok) const
|
|||
unsigned StringView::to_uint(bool& ok) const
|
||||
{
|
||||
unsigned value = 0;
|
||||
for (ssize_t i = 0; i < length(); ++i) {
|
||||
for (size_t i = 0; i < length(); ++i) {
|
||||
if (characters_without_null_termination()[i] < '0' || characters_without_null_termination()[i] > '9') {
|
||||
ok = false;
|
||||
return 0;
|
||||
|
|
|
@ -11,12 +11,12 @@ class StringImpl;
|
|||
class StringView {
|
||||
public:
|
||||
StringView() {}
|
||||
StringView(const char* characters, int length)
|
||||
StringView(const char* characters, size_t length)
|
||||
: m_characters(characters)
|
||||
, m_length(length)
|
||||
{
|
||||
}
|
||||
StringView(const unsigned char* characters, int length)
|
||||
StringView(const unsigned char* characters, size_t length)
|
||||
: m_characters((const char*)characters)
|
||||
, m_length(length)
|
||||
{
|
||||
|
@ -36,14 +36,14 @@ public:
|
|||
bool is_null() const { return !m_characters; }
|
||||
bool is_empty() const { return m_length == 0; }
|
||||
const char* characters_without_null_termination() const { return m_characters; }
|
||||
int length() const { return m_length; }
|
||||
char operator[](int index) const { return m_characters[index]; }
|
||||
size_t length() const { return m_length; }
|
||||
char operator[](size_t index) const { return m_characters[index]; }
|
||||
|
||||
unsigned hash() const;
|
||||
|
||||
bool starts_with(const StringView&) const;
|
||||
|
||||
StringView substring_view(int start, int length) const;
|
||||
StringView substring_view(size_t start, size_t length) const;
|
||||
Vector<StringView> split_view(char, bool keep_empty = false) const;
|
||||
|
||||
// Create a Vector of StringViews split by line endings. As of CommonMark
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
return !cstring;
|
||||
if (!cstring)
|
||||
return false;
|
||||
int other_length = strlen(cstring);
|
||||
size_t other_length = strlen(cstring);
|
||||
if (m_length != other_length)
|
||||
return false;
|
||||
return !memcmp(m_characters, cstring, m_length);
|
||||
|
@ -113,7 +113,7 @@ private:
|
|||
friend class String;
|
||||
const StringImpl* m_impl { nullptr };
|
||||
const char* m_characters { nullptr };
|
||||
int m_length { 0 };
|
||||
size_t m_length { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ TEST_CASE(construct_contents)
|
|||
String test_string = "ABCDEF";
|
||||
EXPECT(!test_string.is_empty());
|
||||
EXPECT(!test_string.is_null());
|
||||
EXPECT_EQ(test_string.length(), 6);
|
||||
EXPECT_EQ(test_string.length(), (int)strlen(test_string.characters()));
|
||||
EXPECT_EQ(test_string.length(), 6u);
|
||||
EXPECT_EQ(test_string.length(), strlen(test_string.characters()));
|
||||
EXPECT(test_string.characters() != nullptr);
|
||||
EXPECT(!strcmp(test_string.characters(), "ABCDEF"));
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ bool URL::parse(const StringView& string)
|
|||
Vector<char, 256> buffer;
|
||||
State state { State::InProtocol };
|
||||
|
||||
int index = 0;
|
||||
size_t index = 0;
|
||||
|
||||
auto peek = [&] {
|
||||
if (index >= string.length())
|
||||
|
|
|
@ -30,7 +30,7 @@ const unsigned char* Utf8View::end_ptr() const
|
|||
|
||||
Utf8CodepointIterator Utf8View::begin() const
|
||||
{
|
||||
return { begin_ptr(), m_string.length() };
|
||||
return { begin_ptr(), (int)m_string.length() };
|
||||
}
|
||||
|
||||
Utf8CodepointIterator Utf8View::end() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue