Skip to content

Commit ddcd8d3

Browse files
authored
Merge pull request swiftlang#20243 from arguiot/patch-1
Updated SwiftPrivate.swift using String Interpolation
2 parents d3e7d59 + 049b89c commit ddcd8d3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

stdlib/private/SwiftPrivate/SwiftPrivate.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -14,18 +14,18 @@ import Swift
1414
import SwiftShims
1515

1616
/// Convert the given numeric value to a hexadecimal string.
17-
// FIXME(integers): support a more general BinaryInteger protocol
17+
// FIXME(integers): support a more general BinaryInteger protocol
1818
public func asHex<T : FixedWidthInteger>(_ x: T) -> String {
19-
return "0x" + String(x, radix: 16)
19+
return "0x\(String(x, radix: 16))"
2020
}
2121

2222
/// Convert the given sequence of numeric values to a string representing
2323
/// their hexadecimal values.
24-
// FIXME(integers): support a more general BinaryInteger protocol
24+
// FIXME(integers): support a more general BinaryInteger protocol
2525
public func asHex<S : Sequence>(_ x: S) -> String
2626
where
2727
S.Element : FixedWidthInteger {
28-
return "[ " + x.lazy.map { asHex($0) }.joined(separator: ", ") + " ]"
28+
return "[ \(x.lazy.map { asHex($0) }.joined(separator: ", ")) ]"
2929
}
3030

3131
/// Compute the prefix sum of `seq`.
@@ -63,14 +63,12 @@ public func withArrayOfCStrings<R>(
6363
let argsCounts = Array(args.map { $0.utf8.count + 1 })
6464
let argsOffsets = [ 0 ] + scan(argsCounts, 0, +)
6565
let argsBufferSize = argsOffsets.last!
66-
6766
var argsBuffer: [UInt8] = []
6867
argsBuffer.reserveCapacity(argsBufferSize)
6968
for arg in args {
7069
argsBuffer.append(contentsOf: arg.utf8)
7170
argsBuffer.append(0)
7271
}
73-
7472
return argsBuffer.withUnsafeMutableBufferPointer {
7573
(argsBuffer) in
7674
let ptr = UnsafeMutableRawPointer(argsBuffer.baseAddress!).bindMemory(

0 commit comments

Comments
 (0)