diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-13 11:49:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-13 19:11:29 +0200 |
commit | 240d2f88d3837449a0d81c6968c1ccadea155180 (patch) | |
tree | 01a4c4a5ed3f3eead57774584f30fde044857761 /Userland | |
parent | b458090d1403095a52f1965ed394fd91d436fff4 (diff) | |
download | serenity-240d2f88d3837449a0d81c6968c1ccadea155180.zip |
LibJS: Convert PropertyName and StringOrSymbol to east-const style
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/PropertyName.h | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/StringOrSymbol.h | 28 |
2 files changed, 20 insertions, 20 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/PropertyName.h b/Userland/Libraries/LibJS/Runtime/PropertyName.h index 45bae0f347..68c3223f4b 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyName.h +++ b/Userland/Libraries/LibJS/Runtime/PropertyName.h @@ -43,20 +43,20 @@ public: VERIFY(index >= 0); } - PropertyName(const char* chars) + PropertyName(char const* chars) : m_type(Type::String) , m_string(FlyString(chars)) { } - PropertyName(const String& string) + PropertyName(String const& string) : m_type(Type::String) , m_string(FlyString(string)) { VERIFY(!string.is_null()); } - PropertyName(const FlyString& string) + PropertyName(FlyString const& string) : m_type(Type::String) , m_string(string) { @@ -70,7 +70,7 @@ public: VERIFY(symbol); } - PropertyName(const StringOrSymbol& string_or_symbol) + PropertyName(StringOrSymbol const& string_or_symbol) { if (string_or_symbol.is_string()) { m_string = string_or_symbol.as_string(); @@ -92,13 +92,13 @@ public: return m_number; } - const FlyString& as_string() const + FlyString const& as_string() const { VERIFY(is_string()); return m_string; } - const Symbol* as_symbol() const + Symbol const* as_symbol() const { VERIFY(is_symbol()); return m_symbol; diff --git a/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h b/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h index 52ea30065c..3ee3513efc 100644 --- a/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h +++ b/Userland/Libraries/LibJS/Runtime/StringOrSymbol.h @@ -17,19 +17,19 @@ class StringOrSymbol { public: StringOrSymbol() = default; - StringOrSymbol(const char* chars) + StringOrSymbol(char const* chars) : m_ptr(StringImpl::create(chars).leak_ref()) { } - StringOrSymbol(const String& string) + StringOrSymbol(String const& string) : m_ptr(string.impl()) { VERIFY(!string.is_null()); as_string_impl().ref(); } - StringOrSymbol(const FlyString& string) + StringOrSymbol(FlyString const& string) : m_ptr(string.impl()) { VERIFY(!string.is_null()); @@ -42,13 +42,13 @@ public: as_string_impl().unref(); } - StringOrSymbol(const Symbol* symbol) + StringOrSymbol(Symbol const* symbol) : m_ptr(symbol) { set_symbol_flag(); } - StringOrSymbol(const StringOrSymbol& other) + StringOrSymbol(StringOrSymbol const& other) { m_ptr = other.m_ptr; if (is_string()) @@ -70,10 +70,10 @@ public: return as_string_impl(); } - ALWAYS_INLINE const Symbol* as_symbol() const + ALWAYS_INLINE Symbol const* as_symbol() const { VERIFY(is_symbol()); - return reinterpret_cast<const Symbol*>(bits() & ~1ul); + return reinterpret_cast<Symbol const*>(bits() & ~1ul); } String to_display_string() const @@ -100,7 +100,7 @@ public: visitor.visit(const_cast<Symbol*>(as_symbol())); } - ALWAYS_INLINE bool operator==(const StringOrSymbol& other) const + ALWAYS_INLINE bool operator==(StringOrSymbol const& other) const { if (is_string()) return other.is_string() && as_string_impl() == other.as_string_impl(); @@ -109,7 +109,7 @@ public: return true; } - StringOrSymbol& operator=(const StringOrSymbol& other) + StringOrSymbol& operator=(StringOrSymbol const& other) { if (this == &other) return *this; @@ -141,23 +141,23 @@ private: ALWAYS_INLINE void set_symbol_flag() { - m_ptr = reinterpret_cast<const void*>(bits() | 1ul); + m_ptr = reinterpret_cast<void const*>(bits() | 1ul); } - ALWAYS_INLINE const StringImpl& as_string_impl() const + ALWAYS_INLINE StringImpl const& as_string_impl() const { VERIFY(is_string()); - return *reinterpret_cast<const StringImpl*>(m_ptr); + return *reinterpret_cast<StringImpl const*>(m_ptr); } - const void* m_ptr { nullptr }; + void const* m_ptr { nullptr }; }; } template<> struct AK::Traits<JS::StringOrSymbol> : public GenericTraits<JS::StringOrSymbol> { - static unsigned hash(const JS::StringOrSymbol& key) + static unsigned hash(JS::StringOrSymbol const& key) { return key.hash(); } |