1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

AK: Inline all the trivial Utf8View functions

This improves parsing time on a large chunk of JS by ~3%.
This commit is contained in:
Andreas Kling 2021-09-18 18:19:21 +02:00
parent 1be4cbd639
commit 391352c112
2 changed files with 15 additions and 52 deletions

View file

@ -11,26 +11,6 @@
namespace AK {
const unsigned char* Utf8View::begin_ptr() const
{
return (const unsigned char*)m_string.characters_without_null_termination();
}
const unsigned char* Utf8View::end_ptr() const
{
return begin_ptr() + m_string.length();
}
Utf8CodePointIterator Utf8View::begin() const
{
return { begin_ptr(), m_string.length() };
}
Utf8CodePointIterator Utf8View::end() const
{
return { end_ptr(), 0 };
}
Utf8CodePointIterator Utf8View::iterator_at_byte_offset(size_t byte_offset) const
{
size_t current_offset = 0;
@ -65,12 +45,6 @@ size_t Utf8View::byte_offset_of(size_t code_point_offset) const
return byte_offset;
}
Utf8View Utf8View::substring_view(size_t byte_offset, size_t byte_length) const
{
StringView string = m_string.substring_view(byte_offset, byte_length);
return Utf8View { string };
}
Utf8View Utf8View::unicode_substring_view(size_t code_point_offset, size_t code_point_length) const
{
if (code_point_length == 0)
@ -214,22 +188,6 @@ Utf8View Utf8View::trim(const Utf8View& characters, TrimMode mode) const
return substring_view(substring_start, substring_length);
}
Utf8CodePointIterator::Utf8CodePointIterator(const unsigned char* ptr, size_t length)
: m_ptr(ptr)
, m_length(length)
{
}
bool Utf8CodePointIterator::operator==(const Utf8CodePointIterator& other) const
{
return m_ptr == other.m_ptr && m_length == other.m_length;
}
bool Utf8CodePointIterator::operator!=(const Utf8CodePointIterator& other) const
{
return !(*this == other);
}
Utf8CodePointIterator& Utf8CodePointIterator::operator++()
{
VERIFY(m_length > 0);