Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3224b48bd584c46f47834f8935371ea84f570481
      
https://github.com/WebKit/WebKit/commit/3224b48bd584c46f47834f8935371ea84f570481
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-08-03 (Mon, 03 Aug 2026)

  Changed paths:
    M Source/WebCore/xml/XMLHttpRequest.cpp
    M Source/WebCore/xml/XMLHttpRequest.h

  Log Message:
  -----------
  Use default member initializers for XMLHttpRequest's bitfields
https://bugs.webkit.org/show_bug.cgi?id=320679
rdar://183663124

Reviewed by Chris Dumez.

XMLHttpRequest declares ten bitfields that were all initialized in the 
constructor's
initializer list, which puts the default state of each flag far from its 
declaration.
All ten were declared as plain unsigned, and the two multi-bit ones, 
m_readyState and
m_responseType, carried a trailing comment naming the enum they actually hold, 
so
every read and write had to launder the value through a static_cast.

Move the defaults to default member initializers and give each field its real 
type:
bool for the eight single-bit flags, State and ResponseType for the two 
multi-bit
fields, which lets the accessors and assignments use the values directly. State 
and
ResponseType both have uint8_t as their underlying type and still fit in three 
bits,
so sizeof(XMLHttpRequest) is unchanged.

* Source/WebCore/xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::XMLHttpRequest): Drop the ten bitfield initializers.
(WebCore::XMLHttpRequest::setResponseType): Assign the enum directly.
(WebCore::XMLHttpRequest::changeState): Ditto.
(WebCore::XMLHttpRequest::abort): Ditto.
(WebCore::XMLHttpRequest::didReachTimeout): Ditto.
* Source/WebCore/xml/XMLHttpRequest.h:
(WebCore::XMLHttpRequest::readyState const): Return m_readyState without a cast.
(WebCore::XMLHttpRequest::responseType const): Ditto for m_responseType.

Canonical link: https://commits.webkit.org/318443@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to