Title: [257727] trunk/Source/WebCore
Revision
257727
Author
[email protected]
Date
2020-03-02 12:45:16 -0800 (Mon, 02 Mar 2020)

Log Message

Reduce size of PerformanceEntry
https://bugs.webkit.org/show_bug.cgi?id=208452

Reviewed by Devin Rousso.

Reduce size of PerformanceEntry by leveraging the fact that it is polymorphic.

* page/PerformanceEntry.cpp:
(WebCore::PerformanceEntry::PerformanceEntry):
* page/PerformanceEntry.h:
(WebCore::PerformanceEntry::name const):
(WebCore::PerformanceEntry::isResource const):
(WebCore::PerformanceEntry::isMark const):
(WebCore::PerformanceEntry::isMeasure const):
(WebCore::PerformanceEntry::entryType const): Deleted.
(WebCore::PerformanceEntry::type const): Deleted.
* page/PerformanceMark.h:
* page/PerformanceMeasure.h:
* page/PerformanceResourceTiming.cpp:
(WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
(WebCore::PerformanceResourceTiming::nextHopProtocol const):
* page/PerformanceResourceTiming.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257726 => 257727)


--- trunk/Source/WebCore/ChangeLog	2020-03-02 20:24:04 UTC (rev 257726)
+++ trunk/Source/WebCore/ChangeLog	2020-03-02 20:45:16 UTC (rev 257727)
@@ -1,3 +1,28 @@
+2020-03-02  Chris Dumez  <[email protected]>
+
+        Reduce size of PerformanceEntry
+        https://bugs.webkit.org/show_bug.cgi?id=208452
+
+        Reviewed by Devin Rousso.
+
+        Reduce size of PerformanceEntry by leveraging the fact that it is polymorphic.
+
+        * page/PerformanceEntry.cpp:
+        (WebCore::PerformanceEntry::PerformanceEntry):
+        * page/PerformanceEntry.h:
+        (WebCore::PerformanceEntry::name const):
+        (WebCore::PerformanceEntry::isResource const):
+        (WebCore::PerformanceEntry::isMark const):
+        (WebCore::PerformanceEntry::isMeasure const):
+        (WebCore::PerformanceEntry::entryType const): Deleted.
+        (WebCore::PerformanceEntry::type const): Deleted.
+        * page/PerformanceMark.h:
+        * page/PerformanceMeasure.h:
+        * page/PerformanceResourceTiming.cpp:
+        (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
+        (WebCore::PerformanceResourceTiming::nextHopProtocol const):
+        * page/PerformanceResourceTiming.h:
+
 2020-03-02  John Wilander  <[email protected]>
 
         ResourceLoadStatistics: Enable cookie blocking and the Storage Access API in ephemeral sessions

Modified: trunk/Source/WebCore/page/PerformanceEntry.cpp (257726 => 257727)


--- trunk/Source/WebCore/page/PerformanceEntry.cpp	2020-03-02 20:24:04 UTC (rev 257726)
+++ trunk/Source/WebCore/page/PerformanceEntry.cpp	2020-03-02 20:45:16 UTC (rev 257727)
@@ -38,12 +38,10 @@
 
 DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(PerformanceEntry);
 
-PerformanceEntry::PerformanceEntry(Type type, const String& name, const String& entryType, double startTime, double finishTime)
+PerformanceEntry::PerformanceEntry(const String& name, double startTime, double finishTime)
     : m_name(name)
-    , m_entryType(entryType)
     , m_startTime(startTime)
     , m_duration(finishTime - startTime)
-    , m_type(type)
 {
 }
 

Modified: trunk/Source/WebCore/page/PerformanceEntry.h (257726 => 257727)


--- trunk/Source/WebCore/page/PerformanceEntry.h	2020-03-02 20:24:04 UTC (rev 257726)
+++ trunk/Source/WebCore/page/PerformanceEntry.h	2020-03-02 20:45:16 UTC (rev 257727)
@@ -43,8 +43,7 @@
 public:
     virtual ~PerformanceEntry();
 
-    String name() const { return m_name; }
-    String entryType() const { return m_entryType; }
+    const String& name() const { return m_name; }
     double startTime() const { return m_startTime; }
     double duration() const { return m_duration; }
 
@@ -55,13 +54,14 @@
         Resource = 1 << 3,
     };
 
-    Type type() const { return m_type; }
+    virtual Type type() const = 0;
+    virtual ASCIILiteral entryType() const = 0;
 
     static Optional<Type> parseEntryTypeString(const String& entryType);
 
-    bool isResource() const { return m_type == Type::Resource; }
-    bool isMark() const { return m_type == Type::Mark; }
-    bool isMeasure() const { return m_type == Type::Measure; }
+    bool isResource() const { return type() == Type::Resource; }
+    bool isMark() const { return type() == Type::Mark; }
+    bool isMeasure() const { return type() == Type::Measure; }
 
     static bool startTimeCompareLessThan(const RefPtr<PerformanceEntry>& a, const RefPtr<PerformanceEntry>& b)
     {
@@ -69,14 +69,12 @@
     }
 
 protected:
-    PerformanceEntry(Type, const String& name, const String& entryType, double startTime, double finishTime);
+    PerformanceEntry(const String& name, double startTime, double finishTime);
 
 private:
     const String m_name;
-    const String m_entryType;
     const double m_startTime;
     const double m_duration;
-    const Type m_type;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/PerformanceMark.h (257726 => 257727)


--- trunk/Source/WebCore/page/PerformanceMark.h	2020-03-02 20:24:04 UTC (rev 257726)
+++ trunk/Source/WebCore/page/PerformanceMark.h	2020-03-02 20:45:16 UTC (rev 257727)
@@ -36,10 +36,13 @@
 
 private:
     PerformanceMark(const String& name, double startTime)
-        : PerformanceEntry(PerformanceEntry::Type::Mark, name, "mark"_s, startTime, startTime)
+        : PerformanceEntry(name, startTime, startTime)
     {
     }
 
+    Type type() const final { return Type::Mark; }
+    ASCIILiteral entryType() const final { return "mark"_s; }
+
     ~PerformanceMark() = default;
 };
 

Modified: trunk/Source/WebCore/page/PerformanceMeasure.h (257726 => 257727)


--- trunk/Source/WebCore/page/PerformanceMeasure.h	2020-03-02 20:24:04 UTC (rev 257726)
+++ trunk/Source/WebCore/page/PerformanceMeasure.h	2020-03-02 20:45:16 UTC (rev 257727)
@@ -36,10 +36,13 @@
 
 private:
     PerformanceMeasure(const String& name, double startTime, double duration)
-        : PerformanceEntry(PerformanceEntry::Type::Measure, name, "measure"_s, startTime, duration)
+        : PerformanceEntry(name, startTime, duration)
     {
     }
 
+    Type type() const final { return Type::Measure; }
+    ASCIILiteral entryType() const final { return "measure"_s; }
+
     ~PerformanceMeasure() = default;
 };
 

Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.cpp (257726 => 257727)


--- trunk/Source/WebCore/page/PerformanceResourceTiming.cpp	2020-03-02 20:24:04 UTC (rev 257726)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.cpp	2020-03-02 20:45:16 UTC (rev 257727)
@@ -80,7 +80,7 @@
 }
 
 PerformanceResourceTiming::PerformanceResourceTiming(MonotonicTime timeOrigin, ResourceTiming&& resourceTiming)
-    : PerformanceEntry(PerformanceEntry::Type::Resource, resourceTiming.url().string(), "resource"_s, entryStartTime(timeOrigin, resourceTiming), entryEndTime(timeOrigin, resourceTiming))
+    : PerformanceEntry(resourceTiming.url().string(), entryStartTime(timeOrigin, resourceTiming), entryEndTime(timeOrigin, resourceTiming))
     , m_initiatorType(resourceTiming.initiator())
     , m_timeOrigin(timeOrigin)
     , m_loadTiming(resourceTiming.loadTiming())
@@ -93,7 +93,7 @@
 
 PerformanceResourceTiming::~PerformanceResourceTiming() = default;
 
-String PerformanceResourceTiming::nextHopProtocol() const
+const String& PerformanceResourceTiming::nextHopProtocol() const
 {
     return m_networkLoadMetrics.protocol;
 }

Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.h (257726 => 257727)


--- trunk/Source/WebCore/page/PerformanceResourceTiming.h	2020-03-02 20:24:04 UTC (rev 257726)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.h	2020-03-02 20:45:16 UTC (rev 257727)
@@ -46,8 +46,8 @@
 public:
     static Ref<PerformanceResourceTiming> create(MonotonicTime timeOrigin, ResourceTiming&&);
 
-    AtomString initiatorType() const { return m_initiatorType; }
-    String nextHopProtocol() const;
+    const AtomString& initiatorType() const { return m_initiatorType; }
+    const String& nextHopProtocol() const;
 
     double workerStart() const;
     double redirectStart() const;
@@ -67,6 +67,9 @@
     PerformanceResourceTiming(MonotonicTime timeOrigin, ResourceTiming&&);
     ~PerformanceResourceTiming();
 
+    Type type() const final { return Type::Resource; }
+    ASCIILiteral entryType() const final { return "resource"_s; }
+
     double networkLoadTimeToDOMHighResTimeStamp(Seconds) const;
 
     AtomString m_initiatorType;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to