diff --git a/Sources/SwiftProtobuf/NameMap.swift b/Sources/SwiftProtobuf/NameMap.swift index f2822e893..14cbf148d 100644 --- a/Sources/SwiftProtobuf/NameMap.swift +++ b/Sources/SwiftProtobuf/NameMap.swift @@ -43,12 +43,8 @@ fileprivate class InternPool { private var interned = [UnsafeRawBufferPointer]() func intern(utf8: String.UTF8View) -> UnsafeRawBufferPointer { - #if swift(>=4.1) let mutable = UnsafeMutableRawBufferPointer.allocate(byteCount: utf8.count, alignment: MemoryLayout.alignment) - #else - let mutable = UnsafeMutableRawBufferPointer.allocate(count: utf8.count) - #endif mutable.copyBytes(from: utf8) let immutable = UnsafeRawBufferPointer(mutable) interned.append(immutable) @@ -56,12 +52,8 @@ fileprivate class InternPool { } func intern(utf8Ptr: UnsafeBufferPointer) -> UnsafeRawBufferPointer { - #if swift(>=4.1) let mutable = UnsafeMutableRawBufferPointer.allocate(byteCount: utf8Ptr.count, alignment: MemoryLayout.alignment) - #else - let mutable = UnsafeMutableRawBufferPointer.allocate(count: utf8.count) - #endif mutable.copyBytes(from: utf8Ptr) let immutable = UnsafeRawBufferPointer(mutable) interned.append(immutable) @@ -70,12 +62,7 @@ fileprivate class InternPool { deinit { for buff in interned { - #if swift(>=4.1) - buff.deallocate() - #else - let p = UnsafeMutableRawPointer(mutating: buff.baseAddress)! - p.deallocate(bytes: buff.count, alignedTo: 1) - #endif + buff.deallocate() } } } diff --git a/Tests/SwiftProtobufTests/Test_JSON.swift b/Tests/SwiftProtobufTests/Test_JSON.swift index e0b7c013d..1f533fd9a 100644 --- a/Tests/SwiftProtobufTests/Test_JSON.swift +++ b/Tests/SwiftProtobufTests/Test_JSON.swift @@ -655,10 +655,6 @@ class Test_JSON: XCTestCase, PBTestHelpers { } func testOptionalString_controlCharacters() { - // This is known to fail on Swift Linux 4.1 and earlier, - // so skip it there. - // See https://bugs.swift.org/browse/SR-4218 for details. -#if !os(Linux) || swift(>=4.2) // Verify that all C0 controls are correctly escaped assertJSONEncode("{\"optionalString\":\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\"}") {(o: inout MessageTestType) in o.optionalString = "\u{00}\u{01}\u{02}\u{03}\u{04}\u{05}\u{06}\u{07}" @@ -672,7 +668,6 @@ class Test_JSON: XCTestCase, PBTestHelpers { assertJSONEncode("{\"optionalString\":\"\\u0018\\u0019\\u001A\\u001B\\u001C\\u001D\\u001E\\u001F\"}") {(o: inout MessageTestType) in o.optionalString = "\u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f}" } -#endif } func testOptionalBytes() throws { diff --git a/Tests/SwiftProtobufTests/Test_TextFormat_proto3.swift b/Tests/SwiftProtobufTests/Test_TextFormat_proto3.swift index 149965cff..8e98d51bf 100644 --- a/Tests/SwiftProtobufTests/Test_TextFormat_proto3.swift +++ b/Tests/SwiftProtobufTests/Test_TextFormat_proto3.swift @@ -655,10 +655,6 @@ class Test_TextFormat_proto3: XCTestCase, PBTestHelpers { } func testEncoding_optionalString_controlCharacters() throws { - // This is known to fail on Swift Linux 4.1 and earlier, - // so skip it there. - // See https://bugs.swift.org/browse/SR-4218 for details. -#if !os(Linux) || swift(>=4.2) assertTextFormatEncode("optional_string: \"\\001\\002\\003\\004\\005\\006\\007\"\n") { (o: inout MessageTestType) in o.optionalString = "\u{01}\u{02}\u{03}\u{04}\u{05}\u{06}\u{07}" @@ -675,7 +671,6 @@ class Test_TextFormat_proto3: XCTestCase, PBTestHelpers { (o: inout MessageTestType) in o.optionalString = "\u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f}" } -#endif } func testEncoding_optionalString_UTF8() throws {