Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OrderedSet] Move RAC utilities to _CollectionsUtilities module
Browse files Browse the repository at this point in the history
lorentey committed Oct 10, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 4916cff commit 9057566
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
//
//===----------------------------------------------------------------------===//

import _CollectionsUtilities

@usableFromInline
internal typealias _UnsafeHashTable = _HashTable.UnsafeHandle

@@ -484,7 +486,7 @@ extension _UnsafeHashTable {
@usableFromInline
internal func clear() {
assertMutable()
_buckets.assign(repeating: 0, count: wordCount)
_buckets.update(repeating: 0, count: wordCount)
}
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@

// The parts of MutableCollection that OrderedSet is able to implement.

import _CollectionsUtilities

extension OrderedSet {
/// Exchanges the values at the specified indices of the set.
///
4 changes: 3 additions & 1 deletion Sources/OrderedCollections/Utilities/_UnsafeBitset.swift
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
//
//===----------------------------------------------------------------------===//

import _CollectionsUtilities

/// A simple bitmap of a fixed number of bits, implementing a sorted set of
/// small nonnegative `Int` values.
///
@@ -184,7 +186,7 @@ extension _UnsafeBitset {
@_effects(releasenone)
internal mutating func clear() {
guard _words.count > 0 else { return }
_words.baseAddress!.assign(repeating: .empty, count: _words.count)
_words.baseAddress!.update(repeating: .empty, count: _words.count)
_count = 0
}

Original file line number Diff line number Diff line change
@@ -10,21 +10,18 @@
//===----------------------------------------------------------------------===//

extension RandomAccessCollection {
@inlinable
@inline(__always)
internal func _index(at offset: Int) -> Index {
@_alwaysEmitIntoClient @inline(__always)
public func _index(at offset: Int) -> Index {
index(startIndex, offsetBy: offset)
}

@inlinable
@inline(__always)
internal func _offset(of index: Index) -> Int {
@_alwaysEmitIntoClient @inline(__always)
public func _offset(of index: Index) -> Int {
distance(from: startIndex, to: index)
}

@inlinable
@inline(__always)
internal subscript(_offset offset: Int) -> Element {
@_alwaysEmitIntoClient @inline(__always)
public subscript(_offset offset: Int) -> Element {
self[_index(at: offset)]
}
}

0 comments on commit 9057566

Please sign in to comment.