⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276502 in webkit


Ignore:
Timestamp:
Apr 23, 2021, 9:55:47 AM (5 years ago)
Author:
Chris Dumez
Message:

Improve our constructDeletedValue() template specializations
https://bugs.webkit.org/show_bug.cgi?id=224889

Reviewed by Darin Adler.

Source/WebCore:

Improve our constructDeletedValue() template specializations and make them more consistent:

  • Use placement-new instead of object assignment since we don't want/need to destroy the existing object (since it is uninitialized).
  • Do as little initialization as possible for performance reasons.
  • Modules/indexeddb/IDBKeyData.cpp:

(WebCore::IDBKeyData::deletedValue): Deleted.

  • Modules/indexeddb/IDBKeyData.h:

(WebCore::IDBKeyDataHashTraits::constructDeletedValue):
(WebCore::IDBKeyDataHashTraits::isDeletedValue):
(WebCore::IDBKeyData::isDeletedValue const): Deleted.

  • Modules/indexeddb/shared/IDBResourceIdentifier.cpp:

(WebCore::IDBResourceIdentifier::deletedValue): Deleted.
(WebCore::IDBResourceIdentifier::isHashTableDeletedValue const): Deleted.

  • Modules/indexeddb/shared/IDBResourceIdentifier.h:

(WebCore::IDBResourceIdentifierHashTraits::constructDeletedValue):
(WebCore::IDBResourceIdentifierHashTraits::isDeletedValue):

  • dom/MessagePortIdentifier.h:

(WTF::HashTraits<WebCore::MessagePortIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::MessagePortIdentifier>::isDeletedValue):

  • history/BackForwardItemIdentifier.h:

(WTF::HashTraits<WebCore::BackForwardItemIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::BackForwardItemIdentifier>::isDeletedValue):

  • layout/LayoutUnits.h:

(WTF::HashTraits<WebCore::Layout::SlotPosition>::constructDeletedValue):
(WTF::HashTraits<WebCore::Layout::SlotPosition>::isDeletedValue):

  • loader/PrivateClickMeasurement.h:

(WebCore::PrivateClickMeasurement::AttributionDestinationSite::matches const):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::constructDeletedValue):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::isDeletedValue):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::constructDeletedValue):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::isDeletedValue):
(WebCore::PrivateClickMeasurement::SourceSite::isHashTableDeletedValue const): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::deletedValue): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::constructDeletedValue): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::deleteValue): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::isDeletedValue const): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::isHashTableDeletedValue const): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::deletedValue): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::constructDeletedValue): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::deleteValue): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::isDeletedValue const): Deleted.

  • page/ClientOrigin.h:

(WTF::HashTraits<WebCore::ClientOrigin>::constructDeletedValue):

  • page/GlobalWindowIdentifier.h:

(WTF::HashTraits<WebCore::GlobalWindowIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::GlobalWindowIdentifier>::isDeletedValue):

  • platform/Cookie.h:

(WTF::HashTraits<WebCore::Cookie>::constructDeletedValue):
(WebCore::Cookie::Cookie): Deleted.

  • platform/graphics/FontCache.cpp:

(WebCore::FontPlatformDataCacheKeyHashTraits::constructDeletedValue):

  • platform/graphics/FontCache.h:

(WebCore::FontCascadeCacheKeyHashTraits::constructDeletedValue):

  • platform/graphics/IntPointHash.h:

(WTF::HashTraits<WebCore::IntPoint>::constructDeletedValue):
(WTF::HashTraits<WebCore::IntPoint>::isDeletedValue):

  • rendering/CSSValueKey.h:

(WTF::HashTraits<WebCore::CSSValueKey>::constructDeletedValue):

  • workers/service/ServiceWorkerClientIdentifier.h:

(WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::isDeletedValue):

Source/WebCore/PAL:

  • pal/SessionID.h:

(WTF::HashTraits<PAL::SessionID>::constructDeletedValue):

Source/WebKit:

Improve our constructDeletedValue() template specializations and make them more consistent:

  • Use placement-new instead of object assignment since we don't want/need to destroy the existing object (since it is uninitialized).
  • Do as little initialization as possible for performance reasons.
  • NetworkProcess/cache/NetworkCache.h:

(WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::constructDeletedValue):
(WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::isDeletedValue):

  • Platform/IPC/StringReference.h:

(WTF::HashTraits<IPC::StringReference>::constructDeletedValue):

  • Shared/CallbackID.h:

(WTF::HashTraits<WebKit::CallbackID>::constructDeletedValue):
(WTF::HashTraits<WebKit::CallbackID>::isDeletedValue):

Source/WebKitLegacy/mac:

Improve our constructDeletedValue() template specializations and make them more consistent:

  • Use placement-new instead of object assignment since we don't want/need to destroy the existing object (since it is uninitialized).
  • Do as little initialization as possible for performance reasons.
  • History/BinaryPropertyList.cpp:

(IntegerArray::integers const):
(IntegerArray::size const):
(IntegerArrayHashTraits::constructDeletedValue):
(IntegerArrayHashTraits::isDeletedValue):
(IntegerArray::markDeleted): Deleted.
(IntegerArray::isDeletedValue const): Deleted.
(IntegerArray::deletedValueSize): Deleted.

Location:
trunk/Source
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r276500 r276502  
     12021-04-23  Chris Dumez  <cdumez@apple.com>
     2
     3        Improve our constructDeletedValue() template specializations
     4        https://bugs.webkit.org/show_bug.cgi?id=224889
     5
     6        Reviewed by Darin Adler.
     7
     8        Improve our constructDeletedValue() template specializations and make them more consistent:
     9        - Use placement-new instead of object assignment since we don't want/need to destroy the
     10          existing object (since it is uninitialized).
     11        - Do as little initialization as possible for performance reasons.
     12
     13        * Modules/indexeddb/IDBKeyData.cpp:
     14        (WebCore::IDBKeyData::deletedValue): Deleted.
     15        * Modules/indexeddb/IDBKeyData.h:
     16        (WebCore::IDBKeyDataHashTraits::constructDeletedValue):
     17        (WebCore::IDBKeyDataHashTraits::isDeletedValue):
     18        (WebCore::IDBKeyData::isDeletedValue const): Deleted.
     19        * Modules/indexeddb/shared/IDBResourceIdentifier.cpp:
     20        (WebCore::IDBResourceIdentifier::deletedValue): Deleted.
     21        (WebCore::IDBResourceIdentifier::isHashTableDeletedValue const): Deleted.
     22        * Modules/indexeddb/shared/IDBResourceIdentifier.h:
     23        (WebCore::IDBResourceIdentifierHashTraits::constructDeletedValue):
     24        (WebCore::IDBResourceIdentifierHashTraits::isDeletedValue):
     25        * dom/MessagePortIdentifier.h:
     26        (WTF::HashTraits<WebCore::MessagePortIdentifier>::constructDeletedValue):
     27        (WTF::HashTraits<WebCore::MessagePortIdentifier>::isDeletedValue):
     28        * history/BackForwardItemIdentifier.h:
     29        (WTF::HashTraits<WebCore::BackForwardItemIdentifier>::constructDeletedValue):
     30        (WTF::HashTraits<WebCore::BackForwardItemIdentifier>::isDeletedValue):
     31        * layout/LayoutUnits.h:
     32        (WTF::HashTraits<WebCore::Layout::SlotPosition>::constructDeletedValue):
     33        (WTF::HashTraits<WebCore::Layout::SlotPosition>::isDeletedValue):
     34        * loader/PrivateClickMeasurement.h:
     35        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::matches const):
     36        (WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::constructDeletedValue):
     37        (WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::isDeletedValue):
     38        (WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::constructDeletedValue):
     39        (WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::isDeletedValue):
     40        (WebCore::PrivateClickMeasurement::SourceSite::isHashTableDeletedValue const): Deleted.
     41        (WebCore::PrivateClickMeasurement::SourceSite::deletedValue): Deleted.
     42        (WebCore::PrivateClickMeasurement::SourceSite::constructDeletedValue): Deleted.
     43        (WebCore::PrivateClickMeasurement::SourceSite::deleteValue): Deleted.
     44        (WebCore::PrivateClickMeasurement::SourceSite::isDeletedValue const): Deleted.
     45        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::isHashTableDeletedValue const): Deleted.
     46        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::deletedValue): Deleted.
     47        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::constructDeletedValue): Deleted.
     48        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::deleteValue): Deleted.
     49        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::isDeletedValue const): Deleted.
     50        * page/ClientOrigin.h:
     51        (WTF::HashTraits<WebCore::ClientOrigin>::constructDeletedValue):
     52        * page/GlobalWindowIdentifier.h:
     53        (WTF::HashTraits<WebCore::GlobalWindowIdentifier>::constructDeletedValue):
     54        (WTF::HashTraits<WebCore::GlobalWindowIdentifier>::isDeletedValue):
     55        * platform/Cookie.h:
     56        (WTF::HashTraits<WebCore::Cookie>::constructDeletedValue):
     57        (WebCore::Cookie::Cookie): Deleted.
     58        * platform/graphics/FontCache.cpp:
     59        (WebCore::FontPlatformDataCacheKeyHashTraits::constructDeletedValue):
     60        * platform/graphics/FontCache.h:
     61        (WebCore::FontCascadeCacheKeyHashTraits::constructDeletedValue):
     62        * platform/graphics/IntPointHash.h:
     63        (WTF::HashTraits<WebCore::IntPoint>::constructDeletedValue):
     64        (WTF::HashTraits<WebCore::IntPoint>::isDeletedValue):
     65        * rendering/CSSValueKey.h:
     66        (WTF::HashTraits<WebCore::CSSValueKey>::constructDeletedValue):
     67        * workers/service/ServiceWorkerClientIdentifier.h:
     68        (WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::constructDeletedValue):
     69        (WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::isDeletedValue):
     70
    1712021-04-23  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    272
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp

    r275151 r276502  
    421421}
    422422
    423 IDBKeyData IDBKeyData::deletedValue()
    424 {
    425     IDBKeyData result;
    426     result.m_isNull = false;
    427     result.m_isDeletedValue = true;
    428     return result;
    429 }
    430 
    431423bool IDBKeyData::isValid() const
    432424{
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h

    r275547 r276502  
    153153    }
    154154
    155     static IDBKeyData deletedValue();
    156     bool isDeletedValue() const { return m_isDeletedValue; }
    157 
    158155    String string() const
    159156    {
     
    189186
    190187private:
     188    friend struct IDBKeyDataHashTraits;
     189
    191190    static void isolatedCopy(const IDBKeyData& source, IDBKeyData& destination);
    192191
     
    208207    static const bool hasIsEmptyValueFunction = true;
    209208
    210     static void constructDeletedValue(IDBKeyData& key)
    211     {
    212         new (&key) IDBKeyData;
    213         key = IDBKeyData::deletedValue();
    214     }
    215 
    216     static bool isDeletedValue(const IDBKeyData& key)
    217     {
    218         return key.isDeletedValue();
    219     }
     209    static void constructDeletedValue(IDBKeyData& key) { key.m_isDeletedValue = true; }
     210    static bool isDeletedValue(const IDBKeyData& key) { return key.m_isDeletedValue; }
    220211
    221212    static IDBKeyData emptyValue()
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp

    r275151 r276502  
    8585}
    8686
    87 IDBResourceIdentifier IDBResourceIdentifier::deletedValue()
    88 {
    89     return IDBResourceIdentifier(IDBConnectionIdentifier { WTF::HashTableDeletedValue }, std::numeric_limits<uint64_t>::max());
    90 }
    91 
    92 bool IDBResourceIdentifier::isHashTableDeletedValue() const
    93 {
    94     return m_idbConnectionIdentifier.isHashTableDeletedValue() && m_resourceNumber == std::numeric_limits<uint64_t>::max();
    95 }
    96 
    9787#if !LOG_DISABLED
    9888
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h

    r275151 r276502  
    5050    explicit IDBResourceIdentifier(const IDBServer::IDBConnectionToClient&);
    5151
    52     static IDBResourceIdentifier deletedValue();
    53     WEBCORE_EXPORT bool isHashTableDeletedValue() const;
    54 
    5552    static IDBResourceIdentifier emptyValue();
    5653    bool isEmpty() const
     
    8582
    8683private:
     84    friend struct IDBResourceIdentifierHashTraits;
     85
    8786    IDBResourceIdentifier(IDBConnectionIdentifier, uint64_t resourceIdentifier);
    8887    IDBConnectionIdentifier m_idbConnectionIdentifier;
     
    112111    static void constructDeletedValue(IDBResourceIdentifier& identifier)
    113112    {
    114         identifier = IDBResourceIdentifier::deletedValue();
     113        new (NotNull, &identifier.m_idbConnectionIdentifier) IDBConnectionIdentifier(WTF::HashTableDeletedValue);
    115114    }
    116115
    117116    static bool isDeletedValue(const IDBResourceIdentifier& identifier)
    118117    {
    119         return identifier.isHashTableDeletedValue();
     118        return identifier.m_idbConnectionIdentifier.isHashTableDeletedValue();
    120119    }
    121120};
  • trunk/Source/WebCore/PAL/ChangeLog

    r276340 r276502  
     12021-04-23  Chris Dumez  <cdumez@apple.com>
     2
     3        Improve our constructDeletedValue() template specializations
     4        https://bugs.webkit.org/show_bug.cgi?id=224889
     5
     6        Reviewed by Darin Adler.
     7
     8        * pal/SessionID.h:
     9        (WTF::HashTraits<PAL::SessionID>::constructDeletedValue):
     10
    1112021-04-20  Brent Fulgham  <bfulgham@apple.com>
    212
  • trunk/Source/WebCore/PAL/pal/SessionID.h

    r264488 r276502  
    116116template<> struct HashTraits<PAL::SessionID> : GenericHashTraits<PAL::SessionID> {
    117117    static PAL::SessionID emptyValue() { return PAL::SessionID(HashTableEmptyValue); }
    118     static void constructDeletedValue(PAL::SessionID& slot) { slot = PAL::SessionID(HashTableDeletedValue); }
     118    static void constructDeletedValue(PAL::SessionID& slot) { new (NotNull, &slot) PAL::SessionID(HashTableDeletedValue); }
    119119    static bool isDeletedValue(const PAL::SessionID& slot) { return slot.isHashTableDeletedValue(); }
    120120};
  • trunk/Source/WebCore/dom/MessagePortIdentifier.h

    r264488 r276502  
    101101    static WebCore::MessagePortIdentifier emptyValue() { return { }; }
    102102
    103     static void constructDeletedValue(WebCore::MessagePortIdentifier& slot) { slot.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(std::numeric_limits<uint64_t>::max()); }
     103    static void constructDeletedValue(WebCore::MessagePortIdentifier& slot) { new (NotNull, &slot.processIdentifier) WebCore::ProcessIdentifier(WTF::HashTableDeletedValue); }
    104104
    105     static bool isDeletedValue(const WebCore::MessagePortIdentifier& slot) { return slot.processIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
     105    static bool isDeletedValue(const WebCore::MessagePortIdentifier& slot) { return slot.processIdentifier.isHashTableDeletedValue(); }
    106106};
    107107
  • trunk/Source/WebCore/history/BackForwardItemIdentifier.h

    r264488 r276502  
    115115    static WebCore::BackForwardItemIdentifier emptyValue() { return { }; }
    116116
    117     static void constructDeletedValue(WebCore::BackForwardItemIdentifier& slot) { slot.processIdentifier = ObjectIdentifier<WebCore::ProcessIdentifierType>(HashTableDeletedValue); }
     117    static void constructDeletedValue(WebCore::BackForwardItemIdentifier& slot) { new (NotNull, &slot.processIdentifier) WebCore::ProcessIdentifier(WTF::HashTableDeletedValue); }
    118118
    119     static bool isDeletedValue(const WebCore::BackForwardItemIdentifier& slot) { return slot.processIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
     119    static bool isDeletedValue(const WebCore::BackForwardItemIdentifier& slot) { return slot.processIdentifier.isHashTableDeletedValue(); }
    120120};
    121121
  • trunk/Source/WebCore/layout/LayoutUnits.h

    r268456 r276502  
    245245    static WebCore::Layout::SlotPosition emptyValue() { return WebCore::Layout::SlotPosition(0, std::numeric_limits<size_t>::max()); }
    246246
    247     static void constructDeletedValue(WebCore::Layout::SlotPosition& slot) { slot = WebCore::Layout::SlotPosition(std::numeric_limits<size_t>::max(), 0); }
    248     static bool isDeletedValue(const WebCore::Layout::SlotPosition& slot) { return slot == WebCore::Layout::SlotPosition(std::numeric_limits<size_t>::max(), 0); }
     247    static void constructDeletedValue(WebCore::Layout::SlotPosition& slot) { slot.column = std::numeric_limits<size_t>::max(); }
     248    static bool isDeletedValue(const WebCore::Layout::SlotPosition& slot) { return slot.column == std::numeric_limits<size_t>::max(); }
    249249};
    250250template<> struct DefaultHash<WebCore::Layout::SlotPosition> : SlotPositionHash { };
  • trunk/Source/WebCore/loader/PrivateClickMeasurement.h

    r275137 r276502  
    8585        }
    8686
    87         explicit SourceSite(WTF::HashTableDeletedValueType)
    88             : registrableDomain(WTF::HashTableDeletedValue)
    89         {
    90         }
    91 
    9287        bool operator==(const SourceSite& other) const
    9388        {
     
    9893        {
    9994            return registrableDomain.matches(url);
    100         }
    101 
    102         bool isHashTableDeletedValue() const
    103         {
    104             return registrableDomain.isHashTableDeletedValue();
    105         }
    106 
    107         static SourceSite deletedValue()
    108         {
    109             return SourceSite { WTF::HashTableDeletedValue };
    110         }
    111 
    112         static void constructDeletedValue(SourceSite& sourceSite)
    113         {
    114             new (&sourceSite) SourceSite;
    115             sourceSite = SourceSite::deletedValue();
    116         }
    117 
    118         void deleteValue()
    119         {
    120             registrableDomain = RegistrableDomain { WTF::HashTableDeletedValue };
    121         }
    122 
    123         bool isDeletedValue() const
    124         {
    125             return isHashTableDeletedValue();
    12695        }
    12796
     
    150119        }
    151120
    152         explicit AttributionDestinationSite(WTF::HashTableDeletedValueType)
    153             : registrableDomain { WTF::HashTableDeletedValue }
    154         {
    155         }
    156 
    157121        explicit AttributionDestinationSite(RegistrableDomain&& domain)
    158122            : registrableDomain { WTFMove(domain) }
     
    168132        {
    169133            return registrableDomain == RegistrableDomain { url };
    170         }
    171        
    172         bool isHashTableDeletedValue() const
    173         {
    174             return registrableDomain.isHashTableDeletedValue();
    175         }
    176 
    177         static AttributionDestinationSite deletedValue()
    178         {
    179             return AttributionDestinationSite { WTF::HashTableDeletedValue };
    180         }
    181 
    182         static void constructDeletedValue(AttributionDestinationSite& destinationSite)
    183         {
    184             new (&destinationSite) AttributionDestinationSite;
    185             destinationSite = AttributionDestinationSite::deletedValue();
    186         }
    187 
    188         void deleteValue()
    189         {
    190             registrableDomain = RegistrableDomain { WTF::HashTableDeletedValue };
    191         }
    192 
    193         bool isDeletedValue() const
    194         {
    195             return isHashTableDeletedValue();
    196134        }
    197135
     
    585523template<> struct HashTraits<WebCore::PrivateClickMeasurement::SourceSite> : GenericHashTraits<WebCore::PrivateClickMeasurement::SourceSite> {
    586524    static WebCore::PrivateClickMeasurement::SourceSite emptyValue() { return { }; }
    587     static void constructDeletedValue(WebCore::PrivateClickMeasurement::SourceSite& slot) { WebCore::PrivateClickMeasurement::SourceSite::constructDeletedValue(slot); }
    588     static bool isDeletedValue(const WebCore::PrivateClickMeasurement::SourceSite& slot) { return slot.isDeletedValue(); }
     525    static void constructDeletedValue(WebCore::PrivateClickMeasurement::SourceSite& slot) { new (NotNull, &slot.registrableDomain) WebCore::RegistrableDomain(WTF::HashTableDeletedValue); }
     526    static bool isDeletedValue(const WebCore::PrivateClickMeasurement::SourceSite& slot) { return slot.registrableDomain.isHashTableDeletedValue(); }
    589527};
    590528
     
    592530template<> struct HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite> : GenericHashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite> {
    593531    static WebCore::PrivateClickMeasurement::AttributionDestinationSite emptyValue() { return { }; }
    594     static void constructDeletedValue(WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { WebCore::PrivateClickMeasurement::AttributionDestinationSite::constructDeletedValue(slot); }
    595     static bool isDeletedValue(const WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { return slot.isDeletedValue(); }
     532    static void constructDeletedValue(WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { new (NotNull, &slot.registrableDomain) WebCore::RegistrableDomain(WTF::HashTableDeletedValue); }
     533    static bool isDeletedValue(const WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { return slot.registrableDomain.isHashTableDeletedValue(); }
    596534};
    597535}
  • trunk/Source/WebCore/page/ClientOrigin.h

    r264488 r276502  
    103103    static WebCore::ClientOrigin emptyValue() { return WebCore::ClientOrigin::emptyKey(); }
    104104
    105     static void constructDeletedValue(WebCore::ClientOrigin& slot) { slot.topOrigin = WebCore::SecurityOriginData(HashTableDeletedValue); }
     105    static void constructDeletedValue(WebCore::ClientOrigin& slot) { new (NotNull, &slot.topOrigin) WebCore::SecurityOriginData(WTF::HashTableDeletedValue); }
    106106    static bool isDeletedValue(const WebCore::ClientOrigin& slot) { return slot.topOrigin.isHashTableDeletedValue(); }
    107107};
  • trunk/Source/WebCore/page/GlobalWindowIdentifier.h

    r264488 r276502  
    9595    static WebCore::GlobalWindowIdentifier emptyValue() { return { }; }
    9696
    97     static void constructDeletedValue(WebCore::GlobalWindowIdentifier& slot) { slot.windowIdentifier = makeObjectIdentifier<WebCore::WindowIdentifierType>(std::numeric_limits<uint64_t>::max()); }
    98     static bool isDeletedValue(const WebCore::GlobalWindowIdentifier& slot) { return slot.windowIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
     97    static void constructDeletedValue(WebCore::GlobalWindowIdentifier& slot) { new (NotNull, &slot.windowIdentifier) WebCore::WindowIdentifier(WTF::HashTableDeletedValue); }
     98    static bool isDeletedValue(const WebCore::GlobalWindowIdentifier& slot) { return slot.windowIdentifier.isHashTableDeletedValue(); }
    9999};
    100100
  • trunk/Source/WebCore/platform/Cookie.h

    r264488 r276502  
    4444struct Cookie {
    4545    Cookie() = default;
    46     Cookie(WTF::HashTableDeletedValueType)
    47         : name(WTF::HashTableDeletedValue)
    48     {
    49     }
    5046
    5147    template<class Encoder> void encode(Encoder&) const;
     
    174170    template<> struct HashTraits<WebCore::Cookie> : GenericHashTraits<WebCore::Cookie> {
    175171        static WebCore::Cookie emptyValue() { return { }; }
    176         static void constructDeletedValue(WebCore::Cookie& slot) { slot = WebCore::Cookie(WTF::HashTableDeletedValue); }
     172        static void constructDeletedValue(WebCore::Cookie& slot) { new (NotNull, &slot.name) String(WTF::HashTableDeletedValue); }
    177173        static bool isDeletedValue(const WebCore::Cookie& slot) { return slot.name.isHashTableDeletedValue(); }
    178174
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r276450 r276502  
    100100    static void constructDeletedValue(FontPlatformDataCacheKey& slot)
    101101    {
    102         new (NotNull, &slot) FontPlatformDataCacheKey { FontDescriptionKey { WTF::HashTableDeletedValue }, { }, { }, { } };
     102        new (NotNull, &slot.descriptionKey) FontDescriptionKey(WTF::HashTableDeletedValue);
    103103    }
    104104    static bool isDeletedValue(const FontPlatformDataCacheKey& key)
  • trunk/Source/WebCore/platform/graphics/FontCache.h

    r276450 r276502  
    208208struct FontCascadeCacheKeyHashTraits : HashTraits<FontCascadeCacheKey> {
    209209    static FontCascadeCacheKey emptyValue() { return { }; }
    210     static void constructDeletedValue(FontCascadeCacheKey& slot) { new (NotNull, &slot) FontCascadeCacheKey { FontDescriptionKey { WTF::HashTableDeletedValue }, { }, { }, { } }; }
     210    static void constructDeletedValue(FontCascadeCacheKey& slot) { new (NotNull, &slot.fontDescriptionKey) FontDescriptionKey(WTF::HashTableDeletedValue); }
    211211    static bool isDeletedValue(const FontCascadeCacheKey& key) { return key.fontDescriptionKey.isHashTableDeletedValue(); }
    212212};
  • trunk/Source/WebCore/platform/graphics/IntPointHash.h

    r264488 r276502  
    3636    static WebCore::IntPoint emptyValue() { return WebCore::IntPoint(0, std::numeric_limits<int>::min()); }
    3737   
    38     static void constructDeletedValue(WebCore::IntPoint& slot) { slot = WebCore::IntPoint(std::numeric_limits<int>::min(), 0); }
    39     static bool isDeletedValue(const WebCore::IntPoint& slot) { return slot == WebCore::IntPoint(std::numeric_limits<int>::min(), 0); }
     38    static void constructDeletedValue(WebCore::IntPoint& slot) { slot.setX(std::numeric_limits<int>::min()); }
     39    static bool isDeletedValue(const WebCore::IntPoint& slot) { return slot.x() == std::numeric_limits<int>::min(); }
    4040};
    4141template<> struct DefaultHash<WebCore::IntPoint> : IntPointHash { };
  • trunk/Source/WebCore/rendering/CSSValueKey.h

    r264488 r276502  
    9090template<> struct HashTraits<WebCore::CSSValueKey> : GenericHashTraits<WebCore::CSSValueKey> {
    9191    static WebCore::CSSValueKey emptyValue() { return WebCore::CSSValueKey { WebCore::CSSValueInvalid, false, false}; }
    92     static void constructDeletedValue(WebCore::CSSValueKey& slot) { slot = WebCore::CSSValueKey { WebCore::CSSValueInvalid, true, true};}
     92    static void constructDeletedValue(WebCore::CSSValueKey& slot) { new (NotNull, &slot) WebCore::CSSValueKey { WebCore::CSSValueInvalid, true, true}; }
    9393    static bool isDeletedValue(const WebCore::CSSValueKey& slot) { return slot.cssValueID == WebCore::CSSValueInvalid && slot.useDarkAppearance && slot.useElevatedUserInterfaceLevel; }
    9494};
  • trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h

    r275650 r276502  
    110110    static WebCore::ServiceWorkerClientIdentifier emptyValue() { return { }; }
    111111
    112     static void constructDeletedValue(WebCore::ServiceWorkerClientIdentifier& slot) { slot.serverConnectionIdentifier = makeObjectIdentifier<WebCore::SWServerConnectionIdentifierType>(std::numeric_limits<uint64_t>::max()); }
     112    static void constructDeletedValue(WebCore::ServiceWorkerClientIdentifier& slot) { new (NotNull, &slot.serverConnectionIdentifier) WebCore::SWServerConnectionIdentifier(HashTableDeletedValue); }
    113113
    114     static bool isDeletedValue(const WebCore::ServiceWorkerClientIdentifier& slot) { return slot.serverConnectionIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
     114    static bool isDeletedValue(const WebCore::ServiceWorkerClientIdentifier& slot) { return slot.serverConnectionIdentifier.isHashTableDeletedValue(); }
    115115};
    116116
  • trunk/Source/WebKit/ChangeLog

    r276497 r276502  
     12021-04-23  Chris Dumez  <cdumez@apple.com>
     2
     3        Improve our constructDeletedValue() template specializations
     4        https://bugs.webkit.org/show_bug.cgi?id=224889
     5
     6        Reviewed by Darin Adler.
     7
     8        Improve our constructDeletedValue() template specializations and make them more consistent:
     9        - Use placement-new instead of object assignment since we don't want/need to destroy the
     10          existing object (since it is uninitialized).
     11        - Do as little initialization as possible for performance reasons.
     12
     13        * NetworkProcess/cache/NetworkCache.h:
     14        (WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::constructDeletedValue):
     15        (WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::isDeletedValue):
     16        * Platform/IPC/StringReference.h:
     17        (WTF::HashTraits<IPC::StringReference>::constructDeletedValue):
     18        * Shared/CallbackID.h:
     19        (WTF::HashTraits<WebKit::CallbackID>::constructDeletedValue):
     20        (WTF::HashTraits<WebKit::CallbackID>::isDeletedValue):
     21
    1222021-04-23  Youenn Fablet  <youenn@apple.com>
    223
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h

    r275650 r276502  
    8484    static WebKit::NetworkCache::GlobalFrameID emptyValue() { return { }; }
    8585
    86     static void constructDeletedValue(WebKit::NetworkCache::GlobalFrameID& slot) { slot.webPageID = makeObjectIdentifier<WebCore::PageIdentifierType>(std::numeric_limits<uint64_t>::max()); }
    87 
    88     static bool isDeletedValue(const WebKit::NetworkCache::GlobalFrameID& slot) { return slot.webPageID.toUInt64() == std::numeric_limits<uint64_t>::max(); }
     86    static void constructDeletedValue(WebKit::NetworkCache::GlobalFrameID& slot) { new (NotNull, &slot.webPageID) WebCore::PageIdentifier(WTF::HashTableDeletedValue); }
     87
     88    static bool isDeletedValue(const WebKit::NetworkCache::GlobalFrameID& slot) { return slot.webPageID.isHashTableDeletedValue(); }
    8989};
    9090
  • trunk/Source/WebKit/Platform/IPC/StringReference.h

    r264488 r276502  
    7474
    7575private:
     76    friend struct HashTraits<IPC::StringReference>;
     77
    7678    const char* m_data;
    7779    size_t m_size;
     
    102104template<> struct HashTraits<IPC::StringReference> : GenericHashTraits<IPC::StringReference> {
    103105    static const bool emptyValueIsZero = 0;
    104     static void constructDeletedValue(IPC::StringReference& stringReference) { stringReference = IPC::StringReference(0, std::numeric_limits<size_t>::max()); }
     106    static void constructDeletedValue(IPC::StringReference& stringReference) { stringReference.m_size = std::numeric_limits<size_t>::max(); }
    105107    static bool isDeletedValue(const IPC::StringReference& stringReference) { return stringReference.size() == std::numeric_limits<size_t>::max(); }
    106108};
  • trunk/Source/WebKit/Shared/CallbackID.h

    r264488 r276502  
    119119template<> struct HashTraits<WebKit::CallbackID> : GenericHashTraits<WebKit::CallbackID> {
    120120    static WebKit::CallbackID emptyValue() { return WebKit::CallbackID(); }
    121     static void constructDeletedValue(WebKit::CallbackID& slot) { slot = WebKit::CallbackID(std::numeric_limits<uint64_t>::max()); }
    122     static bool isDeletedValue(const WebKit::CallbackID& slot) { return slot.m_id == std::numeric_limits<uint64_t>::max(); }
     121    static void constructDeletedValue(WebKit::CallbackID& slot) { HashTraits<uint64_t>::constructDeletedValue(slot.m_id); }
     122    static bool isDeletedValue(const WebKit::CallbackID& slot) { return HashTraits<uint64_t>::isDeletedValue(slot.m_id); }
    123123};
    124124template<> struct DefaultHash<WebKit::CallbackID> : CallbackIDHash { };
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r276247 r276502  
     12021-04-23  Chris Dumez  <cdumez@apple.com>
     2
     3        Improve our constructDeletedValue() template specializations
     4        https://bugs.webkit.org/show_bug.cgi?id=224889
     5
     6        Reviewed by Darin Adler.
     7
     8        Improve our constructDeletedValue() template specializations and make them more consistent:
     9        - Use placement-new instead of object assignment since we don't want/need to destroy the
     10          existing object (since it is uninitialized).
     11        - Do as little initialization as possible for performance reasons.
     12
     13        * History/BinaryPropertyList.cpp:
     14        (IntegerArray::integers const):
     15        (IntegerArray::size const):
     16        (IntegerArrayHashTraits::constructDeletedValue):
     17        (IntegerArrayHashTraits::isDeletedValue):
     18        (IntegerArray::markDeleted): Deleted.
     19        (IntegerArray::isDeletedValue const): Deleted.
     20        (IntegerArray::deletedValueSize): Deleted.
     21
    1222021-04-19  Kimmo Kinnunen  <kkinnunen@apple.com>
    223
  • trunk/Source/WebKitLegacy/mac/History/BinaryPropertyList.cpp

    r275650 r276502  
    5656    IntegerArray(const int* integers, size_t size) : m_integers(integers), m_size(size) { ASSERT(integers); ASSERT(size); }
    5757
    58     void markDeleted() { m_integers = 0; m_size = deletedValueSize(); }
    59     bool isDeletedValue() const { return m_size == deletedValueSize(); }
     58    bool isDeletedValue() const { return HashTraits<size_t>::isDeletedValue(m_size); }
    6059
    6160    const int* integers() const { ASSERT(!isDeletedValue()); return m_integers; }
     
    6362
    6463private:
    65     static size_t deletedValueSize() { return std::numeric_limits<size_t>::max(); }
    66 
     64    friend struct IntegerArrayHashTraits;
    6765    friend bool operator==(const IntegerArray&, const IntegerArray&);
    6866
     
    7775
    7876struct IntegerArrayHashTraits : HashTraits<IntegerArray> {
    79     static void constructDeletedValue(IntegerArray& slot) { slot.markDeleted(); }
    80     static bool isDeletedValue(const IntegerArray& array) { return array.isDeletedValue(); }
     77    static void constructDeletedValue(IntegerArray& slot) { HashTraits<size_t>::constructDeletedValue(slot.m_size); }
     78    static bool isDeletedValue(const IntegerArray& slot) { return HashTraits<size_t>::isDeletedValue(slot.m_size); }
    8179};
    8280
Note: See TracChangeset for help on using the changeset viewer.