From f6498110591ad13e490724e1c6cc59c5c2aa0429 Mon Sep 17 00:00:00 2001 From: Ben Cohen Date: Thu, 29 Nov 2018 16:49:21 -0800 Subject: [PATCH] Change Slice and CollectionOfOne to use _read/_modify --- stdlib/public/core/CollectionOfOne.swift | 4 ++-- stdlib/public/core/Slice.swift | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/public/core/CollectionOfOne.swift b/stdlib/public/core/CollectionOfOne.swift index 98a9d5a5c23e9..1086a661a1290 100644 --- a/stdlib/public/core/CollectionOfOne.swift +++ b/stdlib/public/core/CollectionOfOne.swift @@ -127,9 +127,9 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection { /// valid position in a `CollectionOfOne` instance is `0`. @inlinable // trivial-implementation public subscript(position: Int) -> Element { - get { + _read { _precondition(position == 0, "Index out of range") - return _element + yield _element } _modify { _precondition(position == 0, "Index out of range") diff --git a/stdlib/public/core/Slice.swift b/stdlib/public/core/Slice.swift index 01cf1d675e445..e4d695ce6f5e0 100644 --- a/stdlib/public/core/Slice.swift +++ b/stdlib/public/core/Slice.swift @@ -156,9 +156,9 @@ extension Slice: Collection { @inlinable // generic-performance public subscript(index: Index) -> Base.Element { - get { + _read { _failEarlyRangeCheck(index, bounds: startIndex.. Base.Element { - get { + _read { _failEarlyRangeCheck(index, bounds: startIndex..