mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Backtracing] Add ImageMap instead of just using an Array.
We want to be able to efficiently serialise lists of images, and to do so it makes most sense to create a separate `ImageMap` type. This also provides a useful place to put methods to e.g. find an image by address or by build ID. rdar://124913332
This commit is contained in:
@@ -20,19 +20,23 @@ import Swift
|
||||
/// Sequences you wish to use with `LimitSequence` must use an element type
|
||||
/// that implements this protocol, so that `LimitSequence` can indicate when
|
||||
/// it omits or truncates the sequence.
|
||||
@usableFromInline
|
||||
protocol LimitableElement {
|
||||
static func omitted(_: Int) -> Self
|
||||
static var truncated: Self { get }
|
||||
}
|
||||
|
||||
/// A `Sequence` that adds the ability to limit the output of another sequence.
|
||||
@usableFromInline
|
||||
struct LimitSequence<T: LimitableElement, S: Sequence>: Sequence
|
||||
where S.Element == T
|
||||
{
|
||||
/// The element type, which must conform to `LimitableElement`
|
||||
@usableFromInline
|
||||
typealias Element = T
|
||||
|
||||
/// The source sequence
|
||||
@usableFromInline
|
||||
typealias Source = S
|
||||
|
||||
var source: Source
|
||||
@@ -62,6 +66,7 @@ struct LimitSequence<T: LimitableElement, S: Sequence>: Sequence
|
||||
///
|
||||
/// When `LimitSequence` omits items or truncates the sequence, it will
|
||||
/// insert `.omitted(count)` or `.truncated` items into its output.
|
||||
@usableFromInline
|
||||
init(_ source: Source, limit: Int, offset: Int = 0, top: Int = 0) {
|
||||
self.source = source
|
||||
self.limit = limit
|
||||
@@ -79,6 +84,7 @@ struct LimitSequence<T: LimitableElement, S: Sequence>: Sequence
|
||||
/// This works by buffering an element ahead of where we are in the input
|
||||
/// sequence, so that it can tell whether or not there is more input to
|
||||
/// follow at any given point.
|
||||
@usableFromInline
|
||||
struct Iterator: IteratorProtocol {
|
||||
/// The iterator for the input sequence.
|
||||
var iterator: Source.Iterator
|
||||
|
||||
Reference in New Issue
Block a user