@@ -19,6 +19,7 @@ extension std.string {
19
19
///
20
20
/// - Complexity: O(*n*), where *n* is the number of UTF-8 code units in the
21
21
/// Swift string.
22
+ @inlinable
22
23
public init ( _ string: String ) {
23
24
self = string. withCString ( encodedAs: UTF8 . self) { buffer in
24
25
#if os(Windows)
@@ -32,6 +33,7 @@ extension std.string {
32
33
}
33
34
}
34
35
36
+ @inlinable
35
37
public init ( _ string: UnsafePointer < CChar > ? ) {
36
38
if let str = string {
37
39
#if os(Windows)
@@ -54,6 +56,7 @@ extension std.u16string {
54
56
///
55
57
/// - Complexity: O(*n*), where *n* is the number of UTF-16 code units in the
56
58
/// Swift string.
59
+ @inlinable
57
60
public init ( _ string: String ) {
58
61
self . init ( )
59
62
for char in string. utf16 {
@@ -68,6 +71,7 @@ extension std.u32string {
68
71
///
69
72
/// - Complexity: O(*n*), where *n* is the number of UTF-32 code units in the
70
73
/// Swift string.
74
+ @inlinable
71
75
public init ( _ string: String ) {
72
76
self . init ( )
73
77
for char in string. unicodeScalars {
@@ -79,18 +83,21 @@ extension std.u32string {
79
83
// MARK: Initializing C++ string from a Swift String literal
80
84
81
85
extension std . string : ExpressibleByStringLiteral {
86
+ @inlinable
82
87
public init ( stringLiteral value: String ) {
83
88
self . init ( value)
84
89
}
85
90
}
86
91
87
92
extension std . u16string : ExpressibleByStringLiteral {
93
+ @inlinable
88
94
public init ( stringLiteral value: String ) {
89
95
self . init ( value)
90
96
}
91
97
}
92
98
93
99
extension std . u32string : ExpressibleByStringLiteral {
100
+ @inlinable
94
101
public init ( stringLiteral value: String ) {
95
102
self . init ( value)
96
103
}
@@ -99,14 +106,17 @@ extension std.u32string: ExpressibleByStringLiteral {
99
106
// MARK: Concatenating and comparing C++ strings
100
107
101
108
extension std . string : Equatable , Comparable {
109
+ @inlinable
102
110
public static func == ( lhs: std . string , rhs: std . string ) -> Bool {
103
111
return lhs. compare ( rhs) == 0
104
112
}
105
113
114
+ @inlinable
106
115
public static func < ( lhs: std . string , rhs: std . string ) -> Bool {
107
116
return lhs. compare ( rhs) < 0
108
117
}
109
118
119
+ @inlinable
110
120
public static func += ( lhs: inout std . string , rhs: std . string ) {
111
121
lhs. append ( rhs)
112
122
}
@@ -116,6 +126,7 @@ extension std.string: Equatable, Comparable {
116
126
__appendUnsafe ( other) // ignore the returned pointer
117
127
}
118
128
129
+ @inlinable
119
130
public static func + ( lhs: std . string , rhs: std . string ) -> std . string {
120
131
var copy = lhs
121
132
copy += rhs
@@ -124,14 +135,17 @@ extension std.string: Equatable, Comparable {
124
135
}
125
136
126
137
extension std . u16string : Equatable , Comparable {
138
+ @inlinable
127
139
public static func == ( lhs: std . u16string , rhs: std . u16string ) -> Bool {
128
140
return lhs. compare ( rhs) == 0
129
141
}
130
142
143
+ @inlinable
131
144
public static func < ( lhs: std . u16string , rhs: std . u16string ) -> Bool {
132
145
return lhs. compare ( rhs) < 0
133
146
}
134
147
148
+ @inlinable
135
149
public static func += ( lhs: inout std . u16string , rhs: std . u16string ) {
136
150
lhs. append ( rhs)
137
151
}
@@ -141,6 +155,7 @@ extension std.u16string: Equatable, Comparable {
141
155
__appendUnsafe ( other) // ignore the returned pointer
142
156
}
143
157
158
+ @inlinable
144
159
public static func + ( lhs: std . u16string , rhs: std . u16string ) -> std . u16string {
145
160
var copy = lhs
146
161
copy += rhs
@@ -149,14 +164,17 @@ extension std.u16string: Equatable, Comparable {
149
164
}
150
165
151
166
extension std . u32string : Equatable , Comparable {
167
+ @inlinable
152
168
public static func == ( lhs: std . u32string , rhs: std . u32string ) -> Bool {
153
169
return lhs. compare ( rhs) == 0
154
170
}
155
171
172
+ @inlinable
156
173
public static func < ( lhs: std . u32string , rhs: std . u32string ) -> Bool {
157
174
return lhs. compare ( rhs) < 0
158
175
}
159
176
177
+ @inlinable
160
178
public static func += ( lhs: inout std . u32string , rhs: std . u32string ) {
161
179
lhs. append ( rhs)
162
180
}
@@ -166,6 +184,7 @@ extension std.u32string: Equatable, Comparable {
166
184
__appendUnsafe ( other) // ignore the returned pointer
167
185
}
168
186
187
+ @inlinable
169
188
public static func + ( lhs: std . u32string , rhs: std . u32string ) -> std . u32string {
170
189
var copy = lhs
171
190
copy += rhs
@@ -176,6 +195,7 @@ extension std.u32string: Equatable, Comparable {
176
195
// MARK: Hashing C++ strings
177
196
178
197
extension std . string : Hashable {
198
+ @inlinable
179
199
public func hash( into hasher: inout Hasher ) {
180
200
// Call std::hash<std::string>::operator()
181
201
let cxxHash = __swift_interopHashOfString ( ) . callAsFunction ( self )
@@ -184,6 +204,7 @@ extension std.string: Hashable {
184
204
}
185
205
186
206
extension std . u16string : Hashable {
207
+ @inlinable
187
208
public func hash( into hasher: inout Hasher ) {
188
209
// Call std::hash<std::u16string>::operator()
189
210
let cxxHash = __swift_interopHashOfU16String ( ) . callAsFunction ( self )
@@ -192,6 +213,7 @@ extension std.u16string: Hashable {
192
213
}
193
214
194
215
extension std . u32string : Hashable {
216
+ @inlinable
195
217
public func hash( into hasher: inout Hasher ) {
196
218
// Call std::hash<std::u32string>::operator()
197
219
let cxxHash = __swift_interopHashOfU32String ( ) . callAsFunction ( self )
@@ -202,36 +224,42 @@ extension std.u32string: Hashable {
202
224
// MARK: Getting a Swift description of a C++ string
203
225
204
226
extension std . string : CustomDebugStringConvertible {
227
+ @inlinable
205
228
public var debugDescription : String {
206
229
return " std.string( \( String ( self ) ) ) "
207
230
}
208
231
}
209
232
210
233
extension std . u16string : CustomDebugStringConvertible {
234
+ @inlinable
211
235
public var debugDescription : String {
212
236
return " std.u16string( \( String ( self ) ) ) "
213
237
}
214
238
}
215
239
216
240
extension std . u32string : CustomDebugStringConvertible {
241
+ @inlinable
217
242
public var debugDescription : String {
218
243
return " std.u32string( \( String ( self ) ) ) "
219
244
}
220
245
}
221
246
222
247
extension std . string : CustomStringConvertible {
248
+ @inlinable
223
249
public var description : String {
224
250
return String ( self )
225
251
}
226
252
}
227
253
228
254
extension std . u16string : CustomStringConvertible {
255
+ @inlinable
229
256
public var description : String {
230
257
return String ( self )
231
258
}
232
259
}
233
260
234
261
extension std . u32string : CustomStringConvertible {
262
+ @inlinable
235
263
public var description : String {
236
264
return String ( self )
237
265
}
@@ -247,6 +275,7 @@ extension String {
247
275
/// (`"\u{FFFD}"`).
248
276
///
249
277
/// - Complexity: O(*n*), where *n* is the number of bytes in the C++ string.
278
+ @inlinable
250
279
public init ( _ cxxString: std . string ) {
251
280
let buffer = UnsafeBufferPointer < CChar > (
252
281
start: cxxString. __c_strUnsafe ( ) ,
@@ -265,6 +294,7 @@ extension String {
265
294
///
266
295
/// - Complexity: O(*n*), where *n* is the number of bytes in the C++ UTF-16
267
296
/// string.
297
+ @inlinable
268
298
public init ( _ cxxU16String: std . u16string ) {
269
299
let buffer = UnsafeBufferPointer < UInt16 > (
270
300
start: cxxU16String. __dataUnsafe ( ) ,
@@ -281,6 +311,7 @@ extension String {
281
311
///
282
312
/// - Complexity: O(*n*), where *n* is the number of bytes in the C++ UTF-32
283
313
/// string.
314
+ @inlinable
284
315
public init ( _ cxxU32String: std . u32string ) {
285
316
let buffer = UnsafeBufferPointer < Unicode . Scalar > (
286
317
start: cxxU32String. __dataUnsafe ( ) ,
@@ -303,6 +334,7 @@ extension String {
303
334
///
304
335
/// - Complexity: O(*n*), where *n* is the number of bytes in the C++ string
305
336
/// view.
337
+ @inlinable
306
338
public init ( _ cxxStringView: std . string_view ) {
307
339
let buffer = UnsafeBufferPointer < CChar > (
308
340
start: cxxStringView. __dataUnsafe ( ) ,
@@ -322,6 +354,7 @@ extension String {
322
354
///
323
355
/// - Complexity: O(*n*), where *n* is the number of bytes in the C++ UTF-16
324
356
/// string view.
357
+ @inlinable
325
358
public init ( _ cxxU16StringView: std . u16string_view ) {
326
359
let buffer = UnsafeBufferPointer < UInt16 > (
327
360
start: cxxU16StringView. __dataUnsafe ( ) ,
@@ -339,6 +372,7 @@ extension String {
339
372
///
340
373
/// - Complexity: O(*n*), where *n* is the number of bytes in the C++ UTF-32
341
374
/// string view.
375
+ @inlinable
342
376
public init ( _ cxxU32StringView: std . u32string_view ) {
343
377
let buffer = UnsafeBufferPointer < Unicode . Scalar > (
344
378
start: cxxU32StringView. __dataUnsafe ( ) ,
0 commit comments