summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Utf16String.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-02 17:37:15 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-02 17:39:38 +0200
commit024367d82e59e66390e8a8fc0f7dd866242438f9 (patch)
tree027c34c8ba5410f795cd45d82668f2e9e696a7b0 /Userland/Libraries/LibJS/Runtime/Utf16String.h
parentae0bdda86e9946e8fc09db0c4dc044b2d975d7fa (diff)
downloadserenity-024367d82e59e66390e8a8fc0f7dd866242438f9.zip
LibJS+AK: Use Vector<u16, 1> for UTF-16 string storage
It's very common to encounter single-character strings in JavaScript on the web. We can make such strings significantly lighter by having a 1-character inline capacity on the Vectors.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Utf16String.h')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Utf16String.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Utf16String.h b/Userland/Libraries/LibJS/Runtime/Utf16String.h
index 640de51218..e38e5b4592 100644
--- a/Userland/Libraries/LibJS/Runtime/Utf16String.h
+++ b/Userland/Libraries/LibJS/Runtime/Utf16String.h
@@ -20,18 +20,18 @@ public:
~Utf16StringImpl() = default;
static NonnullRefPtr<Utf16StringImpl> create();
- static NonnullRefPtr<Utf16StringImpl> create(Vector<u16>);
+ static NonnullRefPtr<Utf16StringImpl> create(Vector<u16, 1>);
static NonnullRefPtr<Utf16StringImpl> create(StringView const&);
static NonnullRefPtr<Utf16StringImpl> create(Utf16View const&);
- Vector<u16> const& string() const;
+ Vector<u16, 1> const& string() const;
Utf16View view() const;
private:
Utf16StringImpl() = default;
- explicit Utf16StringImpl(Vector<u16> string);
+ explicit Utf16StringImpl(Vector<u16, 1> string);
- Vector<u16> m_string;
+ Vector<u16, 1> m_string;
};
}
@@ -39,11 +39,11 @@ private:
class Utf16String {
public:
Utf16String();
- explicit Utf16String(Vector<u16>);
+ explicit Utf16String(Vector<u16, 1>);
explicit Utf16String(StringView const&);
explicit Utf16String(Utf16View const&);
- Vector<u16> const& string() const;
+ Vector<u16, 1> const& string() const;
Utf16View view() const;
Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const;
Utf16View substring_view(size_t code_unit_offset) const;