Changeset 181320 in webkit


Ignore:
Timestamp:
Mar 10, 2015 2:21:20 AM (9 years ago)
Author:
zandobersek@gmail.com
Message:

Shrink the CSSPropertyID enum type
https://bugs.webkit.org/show_bug.cgi?id=142456

Reviewed by Sam Weinig.

Specify uint16_t as the base type for the CSSPropertyID enum.
This is enough to cover all of the CSS properties (429 at this moment,
with static_assert covering future changes). It halves the enum type size,
from 4 bytes to 2, reducing the size of various CSSPropertyID containers.

No new tests -- no change in behavior.

  • css/CSSPrimitiveValue.cpp:

(WebCore::propertyName): Remove the unnecessary propertyID < 0 check.

  • css/makeprop.pl:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181317 r181320  
     12015-03-10  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        Shrink the CSSPropertyID enum type
     4        https://bugs.webkit.org/show_bug.cgi?id=142456
     5
     6        Reviewed by Sam Weinig.
     7
     8        Specify uint16_t as the base type for the CSSPropertyID enum.
     9        This is enough to cover all of the CSS properties (429 at this moment,
     10        with static_assert covering future changes). It halves the enum type size,
     11        from 4 bytes to 2, reducing the size of various CSSPropertyID containers.
     12
     13        No new tests -- no change in behavior.
     14
     15        * css/CSSPrimitiveValue.cpp:
     16        (WebCore::propertyName): Remove the unnecessary propertyID < 0 check.
     17        * css/makeprop.pl:
     18
    1192015-03-10  Dan Bernstein  <mitz@apple.com>
    220
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r179100 r181320  
    220220    ASSERT_ARG(propertyID, propertyID >= 0);
    221221    ASSERT_ARG(propertyID, (propertyID >= firstCSSProperty && propertyID < firstCSSProperty + numCSSProperties));
    222 
    223     if (propertyID < 0)
    224         return nullAtom;
    225222
    226223    return getPropertyNameAtomicString(propertyID);
  • trunk/Source/WebCore/css/makeprop.pl

    r179227 r181320  
    133133
    134134namespace WebCore {
     135
     136// Using std::numeric_limits<uint16_t>::max() here would be cleaner,
     137// but is not possible due to missing constexpr support in MSVC 2013.
     138static_assert(numCSSProperties + 1 <= 65535, "CSSPropertyID should fit into uint16_t.");
     139
    135140EOF
    136141
     
    277282namespace WebCore {
    278283
    279 enum CSSPropertyID {
     284enum CSSPropertyID : uint16_t {
    280285    CSSPropertyInvalid = 0,
    281286EOF
Note: See TracChangeset for help on using the changeset viewer.