+2018-07-09 Simon Fraser <simon.fraser@apple.com>
+
+ Shrink WebCore::Pair
+ https://bugs.webkit.org/show_bug.cgi?id=187450
+
+ Reviewed by Sam Weinig.
+
+ Move m_encoding to pack in with m_refCount and remove the virtual destructor,
+ shrinking the class from 40 to 24 bytes.
+ Also make the enum take only a byte, in case it gets used elsewhere
+
+ There are about 500 Pairs on nytimes.com, so this memory saving is non-trivial.
+
+ * css/Pair.h:
+
2018-07-09 Yusuke Suzuki <utatane.tea@gmail.com>
[WebCore] Annotate classes with WTF_MAKE_FAST_ALLOCATED as much as possible
// and border-spacing (all of which are space-separated sets of two values). At the moment we are only using it for
// border-radius and background-size, but (FIXME) border-spacing and background-position could be converted over to use
// it (eliminating some extra -webkit- internal properties).
-class Pair final : public RefCounted<Pair> {
+class Pair : public RefCounted<Pair> {
public:
- enum class IdenticalValueEncoding {
+ enum class IdenticalValueEncoding : uint8_t {
DoNotCoalesce,
Coalesce
};
{
return adoptRef(*new Pair(WTFMove(first), WTFMove(second), encoding));
}
- virtual ~Pair() = default;
-
CSSPrimitiveValue* first() const { return m_first.get(); }
CSSPrimitiveValue* second() const { return m_second.get(); }
bool equals(const Pair& other) const { return compareCSSValuePtr(m_first, other.m_first) && compareCSSValuePtr(m_second, other.m_second); }
private:
- Pair(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second) : m_first(WTFMove(first)), m_second(WTFMove(second)) { }
- Pair(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second, IdenticalValueEncoding encoding) : m_first(WTFMove(first)), m_second(WTFMove(second)), m_encoding(encoding) { }
+ Pair(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second)
+ : m_first(WTFMove(first))
+ , m_second(WTFMove(second))
+ { }
+
+ Pair(RefPtr<CSSPrimitiveValue>&& first, RefPtr<CSSPrimitiveValue>&& second, IdenticalValueEncoding encoding)
+ : m_encoding(encoding)
+ , m_first(WTFMove(first))
+ , m_second(WTFMove(second))
+ { }
+ IdenticalValueEncoding m_encoding { IdenticalValueEncoding::Coalesce };
RefPtr<CSSPrimitiveValue> m_first;
RefPtr<CSSPrimitiveValue> m_second;
- IdenticalValueEncoding m_encoding { IdenticalValueEncoding::Coalesce };
};
} // namespace