From 7646ec34a18a19bc4e20fea4fd1972e625d5e723 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Wed, 21 Jul 2021 19:34:48 +0300 Subject: [PATCH] [TAR] Remove pre-Swift 5.0 crash workaround --- Sources/TAR/TarEntryInfo.swift | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/Sources/TAR/TarEntryInfo.swift b/Sources/TAR/TarEntryInfo.swift index 3de3a8d9..65450e0a 100644 --- a/Sources/TAR/TarEntryInfo.swift +++ b/Sources/TAR/TarEntryInfo.swift @@ -404,21 +404,8 @@ public struct TarEntryInfo: ContainerEntryInfo { // Looking for the last slash in the potential prefix. -1 if not found. // It determines the end of the actual prefix and the beginning of the updated name field. - #if (swift(>=4.1.50) || (swift(>=3.4) && !swift(>=4.0))) || !os(Linux) - let lastPrefixSlashIndex = nameData.prefix(upTo: maxPrefixLength) - .range(of: Data([0x2f]), options: .backwards)?.lowerBound ?? -1 - #else - // TODO: This is a workaround for runtime crash in `Data.prefix(upTo:).range(of:options:)` on Linux with - // Swift 4.1. It seems like it is fixed in 4.2 and master snapshots, so it will be removed when Swift - // 5.0 is released. - var lastPrefixSlashIndex = -1 - for i in stride(from: maxPrefixLength - 1, through: 0, by: -1) { - if nameData[i] == 0x2f { - lastPrefixSlashIndex = i - break - } - } - #endif + let lastPrefixSlashIndex = nameData.prefix(upTo: maxPrefixLength) + .range(of: Data([0x2f]), options: .backwards)?.lowerBound ?? -1 let updatedNameLength = nameData.count - lastPrefixSlashIndex - 1 let prefixLength = lastPrefixSlashIndex