2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -14,18 +14,18 @@ import Swift
14
14
import SwiftShims
15
15
16
16
/// 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
18
18
public func asHex< T : FixedWidthInteger > ( _ x: T ) -> String {
19
- return " 0x " + String( x, radix: 16 )
19
+ return " 0x \( String ( x, radix: 16 ) ) "
20
20
}
21
21
22
22
/// Convert the given sequence of numeric values to a string representing
23
23
/// their hexadecimal values.
24
- // FIXME(integers): support a more general BinaryInteger protocol
24
+ // FIXME(integers): support a more general BinaryInteger protocol
25
25
public func asHex< S : Sequence > ( _ x: S ) -> String
26
26
where
27
27
S. Element : FixedWidthInteger {
28
- return " [ " + x. lazy. map { asHex ( $0) } . joined ( separator: " , " ) + " ] "
28
+ return " [ \( x. lazy. map { asHex ( $0) } . joined ( separator: " , " ) ) ] "
29
29
}
30
30
31
31
/// Compute the prefix sum of `seq`.
@@ -63,14 +63,12 @@ public func withArrayOfCStrings<R>(
63
63
let argsCounts = Array ( args. map { $0. utf8. count + 1 } )
64
64
let argsOffsets = [ 0 ] + scan( argsCounts, 0 , + )
65
65
let argsBufferSize = argsOffsets. last!
66
-
67
66
var argsBuffer : [ UInt8 ] = [ ]
68
67
argsBuffer. reserveCapacity ( argsBufferSize)
69
68
for arg in args {
70
69
argsBuffer. append ( contentsOf: arg. utf8)
71
70
argsBuffer. append ( 0 )
72
71
}
73
-
74
72
return argsBuffer. withUnsafeMutableBufferPointer {
75
73
( argsBuffer) in
76
74
let ptr = UnsafeMutableRawPointer ( argsBuffer. baseAddress!) . bindMemory (
0 commit comments