Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 15e2f508ca1a41912a0d13c510a4c5704883f2b9
      
https://github.com/WebKit/WebKit/commit/15e2f508ca1a41912a0d13c510a4c5704883f2b9
  Author: Geoffrey Garen <gga...@apple.com>
  Date:   2024-11-16 (Sat, 16 Nov 2024)

  Changed paths:
    M Source/WTF/WTF.xcodeproj/project.pbxproj
    M Source/WTF/wtf/CMakeLists.txt
    M Source/WTF/wtf/HexNumber.cpp
    M Source/WTF/wtf/IndexedRange.h
    M Source/WTF/wtf/JSONValues.cpp
    A Source/WTF/wtf/ZippedRange.h
    M Source/WebGPU/WebGPU/CommandEncoder.mm
    M Source/WebGPU/WebGPU/RenderBundleEncoder.mm
    M Source/WebGPU/WebGPU/RenderPassEncoder.mm
    M Source/WebGPU/WebGPU/RenderPipeline.mm
    M Source/WebKit/UIProcess/API/Cocoa/_WKTouchEventGenerator.mm

  Log Message:
  -----------
  Added ZippedRange, and ported some improvements from it to IndexedRange
https://bugs.webkit.org/show_bug.cgi?id=283249
rdar://140054429

Reviewed by Chris Dumez.

We use these types to assist bounds-safe iteration.

* Source/WTF/WTF.xcodeproj/project.pbxproj: New header.

* Source/WTF/wtf/CMakeLists.txt: New header.

* Source/WTF/wtf/IndexedRange.h:
(WTF::BoundsCheckedIterator::begin):
(WTF::BoundsCheckedIterator::end): Use a universal reference argument type and
std::forward so that we can handle const / non-const and other variations.
Previously we only supported const&, but sometimes you want to assign while
you iterate.

(WTF::BoundsCheckedIterator::operator* const): Support non-copyable types and
avoid expensive copies by returning the universal reference type.

'auto' return values decay "T&" to "T", which often creates a copy. 'auto&&'
does not decay, and returns "T&" for "T&".

If you are as confused as I am, these sources may help you:

https://skebanga.github.io/structured-bindings/
https://devblogs.microsoft.com/oldnewthing/20201015-00/?p=104369
https://devblogs.microsoft.com/oldnewthing/20201014-00/?p=104367

(WTF::BoundsCheckedIterator::BoundsCheckedIterator):
(WTF::boundsCheckedBegin):
(WTF::boundsCheckedEnd): No need to have Collection as a part of our type;
it's only needed in our constructor.

(WTF::IndexedRangeIterator::operator*): Just use pair. Tuple is more fancy
than we need to be.

(WTF::IndexedRange::IndexedRange): Use the universal reference type.

(WTF::indexedRange): We need to use a helper function instead of instantiating
IndexedRange directly in order to trigger template argument deduction.

* Source/WTF/wtf/JSONValues.cpp: Initial use of ZippedRange.

* Source/WTF/wtf/ZippedRange.h: Added. Same as IndexedRange, except we keep
two iterators instead of an index and an iterator. There are fancier ways to
do this, but this seems to fit our needs.

Here's one fancier option:
https://github.com/alemuntoni/zip-views

(WTF::ZippedRangeIterator::ZippedRangeIterator):
(WTF::ZippedRangeIterator::operator++):
(WTF::ZippedRangeIterator::operator*):
(WTF::ZippedRangeIterator::operator== const):
(WTF::ZippedRange::ZippedRange):
(WTF::ZippedRange::begin):
(WTF::ZippedRange::end):
(WTF::zippedRange):

* Source/WebGPU/WebGPU/CommandEncoder.mm:
(WebGPU::CommandEncoder::beginRenderPass):
* Source/WebGPU/WebGPU/RenderBundleEncoder.mm:
(WebGPU::Device::createRenderBundleEncoder):
* Source/WebGPU/WebGPU/RenderPassEncoder.mm:
(WebGPU::m_maxDrawCount):
* Source/WebGPU/WebGPU/RenderPipeline.mm:
(WebGPU::createVertexDescriptor):
* Source/WebKit/UIProcess/API/Cocoa/_WKTouchEventGenerator.mm:
(-[_WKTouchEventGenerator init]):
(-[_WKTouchEventGenerator _updateTouchPoints:window:]):
(-[_WKTouchEventGenerator touchDownAtPoints:touchCount:window:]):
(-[_WKTouchEventGenerator liftUpAtPoints:touchCount:window:]): Updated to use
indexedRange() instead of IndexedRange(), since indexedRange() is now required
for template argument deduction.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to