Skip to content

Instantly share code, notes, and snippets.

View Letanyan's full-sized avatar

Letanyan Arumugam Letanyan

  • South Africa, Pretoria
View GitHub Profile
@Letanyan
Letanyan / OffsetBenchmarks.swift
Last active April 16, 2019 18:37
Benchmarking the performance of various ways to access a collection using an offset
import Dispatch
extension BidirectionalCollection {
subscript(offset o: Int) -> Element {
if o < 0 {
return self[index(endIndex, offsetBy: o)]
} else {
return self[index(startIndex, offsetBy: o)]
}
}