Skip to content

Commit a11c1ba

Browse files
committed
Sources: remove now deprecated 'characters'
With latest Swift version, using `characters` now generates an error ``` Apple Swift version 4.0.1 (swiftlang-900.0.68 clang-900.0.38) Target: x86_64-apple-macosx10.9 ```
1 parent 1100fba commit a11c1ba

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

Sources/PluginLibrary/NamingUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fileprivate func sanitizeTypeName(_ s: String, disambiguator: String) -> String
189189
// conflict. This can be resolved recursively by stripping
190190
// the disambiguator, sanitizing the root, then re-adding the
191191
// disambiguator:
192-
let e = s.index(s.endIndex, offsetBy: -disambiguator.characters.count)
192+
let e = s.index(s.endIndex, offsetBy: -disambiguator.count)
193193
#if swift(>=4.0)
194194
let truncated = String(s[..<e])
195195
#else
@@ -300,7 +300,7 @@ public enum NamingUtils {
300300
// "pacakge.some_name" -> "Package_SomeName"
301301
var makeUpper = true
302302
var prefix = ""
303-
for c in protoPackage.characters {
303+
for c in protoPackage {
304304
if c == "_" {
305305
makeUpper = true
306306
} else if c == "." {

Sources/SwiftProtobuf/Google_Protobuf_Any+Registry.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Dispatch
2121

2222
internal func buildTypeURL(forMessage message: Message, typePrefix: String) -> String {
2323
var url = typePrefix
24-
if typePrefix.isEmpty || typePrefix.characters.last != "/" {
24+
if typePrefix.isEmpty || typePrefix.last != "/" {
2525
url += "/"
2626
}
2727
return url + typeName(fromMessage: message)

Sources/SwiftProtobuf/Google_Protobuf_Duration+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private func parseDuration(text: String) throws -> (Int64, Int32) {
2323
var digits = [Character]()
2424
var digitCount = 0
2525
var total = 0
26-
var chars = text.characters.makeIterator()
26+
var chars = text.makeIterator()
2727
var seconds: Int64?
2828
var nanos: Int32 = 0
2929
while let c = chars.next() {

Sources/SwiftProtobuf/Google_Protobuf_FieldMask+Extensions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
private func ProtoToJSON(name: String) -> String? {
2020
var jsonPath = String()
21-
var chars = name.characters.makeIterator()
21+
var chars = name.makeIterator()
2222
while let c = chars.next() {
2323
switch c {
2424
case "_":
@@ -43,7 +43,7 @@ private func ProtoToJSON(name: String) -> String? {
4343

4444
private func JSONToProto(name: String) -> String? {
4545
var path = String()
46-
for c in name.characters {
46+
for c in name {
4747
switch c {
4848
case "_":
4949
return nil
@@ -61,7 +61,7 @@ private func parseJSONFieldNames(names: String) -> [String]? {
6161
var fieldNameCount = 0
6262
var fieldName = String()
6363
var split = [String]()
64-
for c: Character in names.characters {
64+
for c: Character in names {
6565
switch c {
6666
case ",":
6767
if fieldNameCount == 0 {

Sources/SwiftProtobuf/NameMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private func toJsonFieldName(_ s: String) -> String {
2424
var result = String()
2525
var capitalizeNext = false
2626

27-
for c in s.characters {
27+
for c in s {
2828
if c == "_" {
2929
capitalizeNext = true
3030
} else if capitalizeNext {

Sources/protoc-gen-swift/StringUtils.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func splitPath(pathname: String) -> (dir:String, base:String, suffix:String) {
1515
var base = ""
1616
var suffix = ""
1717

18-
for c in pathname.characters {
18+
for c in pathname {
1919
if c == "/" {
2020
dir += base + suffix + String(c)
2121
base = ""
@@ -27,7 +27,7 @@ func splitPath(pathname: String) -> (dir:String, base:String, suffix:String) {
2727
suffix += String(c)
2828
}
2929
}
30-
if suffix.characters.first != "." {
30+
if suffix.first != "." {
3131
base += suffix
3232
suffix = ""
3333
}
@@ -47,7 +47,7 @@ func partition(string: String, atFirstOccurrenceOf substring: String) -> (String
4747
}
4848

4949
func parseParameter(string: String?) -> [(key:String, value:String)] {
50-
guard let string = string, string.characters.count > 0 else {
50+
guard let string = string, string.count > 0 else {
5151
return []
5252
}
5353
let parts = string.components(separatedBy: ",")

Tests/SwiftProtobufTests/Test_JSON.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class Test_JSON: XCTestCase, PBTestHelpers {
138138
configureLargeObject(&m)
139139
let s = try m.jsonString()
140140
var truncated = ""
141-
for c in s.characters {
141+
for c in s {
142142
truncated.append(c)
143143
do {
144144
_ = try MessageTestType(jsonString: truncated)

0 commit comments

Comments
 (0)