diff options
author | Sam Atkins <atkinssj@gmail.com> | 2021-08-20 12:08:53 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-25 12:14:34 +0200 |
commit | 6d39f4342d48e0be49f217ab491407123547e99f (patch) | |
tree | 422bbc12b867e7c39107ad922ce30a16e670d26a /Userland/Libraries/LibWeb/CSS/StyleValue.h | |
parent | d2342caf426cecbeb3c28b77a7fa2e226228d385 (diff) | |
download | serenity-6d39f4342d48e0be49f217ab491407123547e99f.zip |
LibWeb: Use single shared instance of Inherit/InitialStyleValue
These are always the same, so we can avoid allocating them repeatedly
and just use a single instance of each. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/StyleValue.h')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index e294b8988e..fb53235286 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -534,7 +534,11 @@ private: class InitialStyleValue final : public StyleValue { public: - static NonnullRefPtr<InitialStyleValue> create() { return adopt_ref(*new InitialStyleValue); } + static NonnullRefPtr<InitialStyleValue> the() + { + static NonnullRefPtr<InitialStyleValue> instance = adopt_ref(*new InitialStyleValue); + return instance; + } virtual ~InitialStyleValue() override { } String to_string() const override { return "initial"; } @@ -548,7 +552,11 @@ private: class InheritStyleValue final : public StyleValue { public: - static NonnullRefPtr<InheritStyleValue> create() { return adopt_ref(*new InheritStyleValue); } + static NonnullRefPtr<InheritStyleValue> the() + { + static NonnullRefPtr<InheritStyleValue> instance = adopt_ref(*new InheritStyleValue); + return instance; + } virtual ~InheritStyleValue() override { } String to_string() const override { return "inherit"; } |