Skip to content

Commit

Permalink
[gardening] Don't need to use String.characters now
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesyo committed Oct 6, 2017
1 parent 00a2f3b commit d406354
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Source/CarthageKit/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public struct BuildSettings {
}

let trimSet = CharacterSet.whitespacesAndNewlines
let components = line.characters
let components = line
.split(maxSplits: 1) { $0 == "=" }
.map { String($0).trimmingCharacters(in: trimSet) }
.map { $0.trimmingCharacters(in: trimSet) }

if components.count == 2 {
currentSettings[components[0]] = components[1]
Expand Down Expand Up @@ -138,7 +138,7 @@ public struct BuildSettings {
let supportedPlatforms = self["SUPPORTED_PLATFORMS"]

if let supportedPlatforms = supportedPlatforms.value {
let platforms = supportedPlatforms.characters.split { $0 == " " }.map(String.init)
let platforms = supportedPlatforms.split { $0 == " " }.map(String.init)
return SignalProducer<String, CarthageError>(platforms)
.map { platform in SignalProducer(result: SDK.from(string: platform)) }
.flatten(.merge)
Expand Down
7 changes: 3 additions & 4 deletions Source/CarthageKit/Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public func listTags(_ repositoryFileURL: URL) -> SignalProducer<String, Carthag
return launchGitTask([ "tag", "--column=never" ], repositoryFileURL: repositoryFileURL)
.flatMap(.concat) { (allTags: String) -> SignalProducer<String, CarthageError> in
return SignalProducer { observer, lifetime in
let range = allTags.characters.startIndex..<allTags.characters.endIndex
let range = allTags.startIndex...
allTags.enumerateSubstrings(in: range, options: [ .byLines, .reverse ]) { line, _, _, stop in
if lifetime.hasEnded {
stop = true
Expand Down Expand Up @@ -238,7 +238,7 @@ private func checkoutSubmodule(_ submodule: Submodule, _ submoduleWorkingDirecto
/// Parses each key/value entry from the given config file contents, optionally
/// stripping a known prefix/suffix off of each key.
private func parseConfigEntries(_ contents: String, keyPrefix: String = "", keySuffix: String = "") -> SignalProducer<(String, String), NoError> {
let entries = contents.characters.split(omittingEmptySubsequences: true) { $0 == "\0" }
let entries = contents.split(omittingEmptySubsequences: true) { $0 == "\0" }

return SignalProducer { observer, lifetime in
for entry in entries {
Expand Down Expand Up @@ -285,7 +285,7 @@ internal func list(treeish: String, atPath path: String, inRepository repository
repositoryFileURL: repositoryURL
)
.flatMap(.merge) { (output: String) -> SignalProducer<String, CarthageError> in
return SignalProducer(output.characters.lazy.split(separator: "\0").map { String($0) })
return SignalProducer(output.lazy.split(separator: "\0").map(String.init))
}
}

Expand All @@ -298,7 +298,6 @@ public func submoduleSHAForPath(_ repositoryFileURL: URL, _ path: String, revisi
// Example:
// 160000 commit 083fd81ecf00124cbdaa8f86ef10377737f6325a External/ObjectiveGit
let components = string
.characters
.split(maxSplits: 3, omittingEmptySubsequences: true) { (char: Character) in
char == " " || char == "\t"
}
Expand Down
3 changes: 1 addition & 2 deletions Source/CarthageKit/GitHub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private func credentialsFromGit(forServer server: Server) -> (String, String)? {
return string.linesProducer
}
.reduce(into: [:]) { (values: inout [String: String], line: String) in
let parts = line.characters
let parts = line
.split(maxSplits: 1, omittingEmptySubsequences: true) { $0 == "=" }
.map(String.init)

Expand Down Expand Up @@ -115,7 +115,6 @@ private func tokenFromEnvironment(forServer server: Server) -> String? {
// Treat the input as comma-separated series of domains and tokens.
// (e.g., `GITHUB_ACCESS_TOKEN="github.com=XXXXXXXXXXXXX,enterprise.local/ghe=YYYYYYYYY"`)
let records = accessTokenInput
.characters
.split(omittingEmptySubsequences: true) { $0 == "," }
.reduce(into: [:]) { (values: inout [String: String], record) in
let parts = record.split(maxSplits: 1, omittingEmptySubsequences: true) { $0 == "=" }.map(String.init)
Expand Down
6 changes: 3 additions & 3 deletions Source/CarthageKit/GitURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public struct GitURL {
// scp syntax.
var strippedURLString = urlString

if let index = strippedURLString.characters.index(of: "@") {
if let index = strippedURLString.index(of: "@") {
strippedURLString.removeSubrange(strippedURLString.startIndex...index)
}

var host = ""
if let index = strippedURLString.characters.index(of: ":") {
if let index = strippedURLString.index(of: ":") {
host = String(strippedURLString[strippedURLString.startIndex..<index])
strippedURLString.removeSubrange(strippedURLString.startIndex...index)
}
Expand All @@ -47,7 +47,7 @@ public struct GitURL {

/// The name of the repository, if it can be inferred from the URL.
public var name: String? {
let components = urlString.characters.split(omittingEmptySubsequences: true) { $0 == "/" }
let components = urlString.split(omittingEmptySubsequences: true) { $0 == "/" }

return components
.last
Expand Down
2 changes: 0 additions & 2 deletions Source/CarthageKit/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ extension SemanticVersion: Scannable {
}

let components = (unwrapped as String)
.characters
.split(omittingEmptySubsequences: true) { $0 == "." }
.map(String.init)
if components.isEmpty {
return .failure(ScannableError(message: "expected version", currentLine: scanner.currentLine))
}
Expand Down
2 changes: 1 addition & 1 deletion Source/XCDBLD/ProjectLocator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extension ProjectLocator: Comparable {
return false

default:
return lhs.fileURL.path.characters.lexicographicallyPrecedes(rhs.fileURL.path.characters)
return lhs.fileURL.path.lexicographicallyPrecedes(rhs.fileURL.path)
}
}
}
Expand Down

0 comments on commit d406354

Please sign in to comment.