From 56b82b1b7f0212cf0ceaee4dc010d605adef80f3 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 30 Aug 2021 13:25:58 -0700 Subject: [PATCH] Freeze some types for consistency with their inlinable initializers Note: @frozen does *not* mean that we actually consider these struct types frozen. Their layout may arbitrarily change between even minor releases. --- Sources/DequeModule/Deque+Collection.swift | 1 + Sources/DequeModule/Deque._Storage.swift | 1 + Sources/DequeModule/Deque._UnsafeHandle.swift | 1 + Sources/DequeModule/_DequeBuffer.swift | 1 + Sources/DequeModule/_UnsafeWrappedBuffer.swift | 2 ++ .../OrderedSet/OrderedSet+UnorderedView.swift | 1 + 6 files changed, 7 insertions(+) diff --git a/Sources/DequeModule/Deque+Collection.swift b/Sources/DequeModule/Deque+Collection.swift index d88846626..e1614b6a5 100644 --- a/Sources/DequeModule/Deque+Collection.swift +++ b/Sources/DequeModule/Deque+Collection.swift @@ -16,6 +16,7 @@ extension Deque: Sequence { // conversions from indices to storage slots. /// An iterator over the members of a deque. + @frozen public struct Iterator: IteratorProtocol { @usableFromInline internal var _storage: Deque._Storage diff --git a/Sources/DequeModule/Deque._Storage.swift b/Sources/DequeModule/Deque._Storage.swift index 6e7de6d7c..2c0a5d330 100644 --- a/Sources/DequeModule/Deque._Storage.swift +++ b/Sources/DequeModule/Deque._Storage.swift @@ -10,6 +10,7 @@ //===----------------------------------------------------------------------===// extension Deque { + @frozen @usableFromInline struct _Storage { @usableFromInline diff --git a/Sources/DequeModule/Deque._UnsafeHandle.swift b/Sources/DequeModule/Deque._UnsafeHandle.swift index b802821e3..ed32110d3 100644 --- a/Sources/DequeModule/Deque._UnsafeHandle.swift +++ b/Sources/DequeModule/Deque._UnsafeHandle.swift @@ -10,6 +10,7 @@ //===----------------------------------------------------------------------===// extension Deque { + @frozen @usableFromInline internal struct _UnsafeHandle { @usableFromInline diff --git a/Sources/DequeModule/_DequeBuffer.swift b/Sources/DequeModule/_DequeBuffer.swift index 62fd9e214..bc0df278a 100644 --- a/Sources/DequeModule/_DequeBuffer.swift +++ b/Sources/DequeModule/_DequeBuffer.swift @@ -9,6 +9,7 @@ // //===----------------------------------------------------------------------===// +@_fixed_layout @usableFromInline internal class _DequeBuffer: ManagedBuffer<_DequeBufferHeader, Element> { @inlinable diff --git a/Sources/DequeModule/_UnsafeWrappedBuffer.swift b/Sources/DequeModule/_UnsafeWrappedBuffer.swift index 0424403e6..06a0a580c 100644 --- a/Sources/DequeModule/_UnsafeWrappedBuffer.swift +++ b/Sources/DequeModule/_UnsafeWrappedBuffer.swift @@ -9,6 +9,7 @@ // //===----------------------------------------------------------------------===// +@frozen @usableFromInline internal struct _UnsafeWrappedBuffer { @usableFromInline @@ -51,6 +52,7 @@ internal struct _UnsafeWrappedBuffer { internal var count: Int { first.count + (second?.count ?? 0) } } +@frozen @usableFromInline internal struct _UnsafeMutableWrappedBuffer { @usableFromInline diff --git a/Sources/OrderedCollections/OrderedSet/OrderedSet+UnorderedView.swift b/Sources/OrderedCollections/OrderedSet/OrderedSet+UnorderedView.swift index cc679d43d..b0222a64c 100644 --- a/Sources/OrderedCollections/OrderedSet/OrderedSet+UnorderedView.swift +++ b/Sources/OrderedCollections/OrderedSet/OrderedSet+UnorderedView.swift @@ -12,6 +12,7 @@ extension OrderedSet { /// An unordered view into an ordered set, providing `SetAlgebra` /// conformance. + @frozen public struct UnorderedView { public typealias Element = OrderedSet.Element