[stdlib] String API Review: hide "split" and "lines"

Swift SVN r18514
This commit is contained in:
Dave Abrahams
2014-05-21 20:30:23 +00:00
parent ee261fb348
commit 8445618f1d
4 changed files with 8 additions and 8 deletions

View File

@@ -41,11 +41,11 @@ extension String {
input: Repeat(count: count, repeatedValue: c.value))
}
var lines : String[] {
return split("\n")
var _lines : String[] {
return _split("\n")
}
func split(separator: UnicodeScalar) -> String[] {
func _split(separator: UnicodeScalar) -> String[] {
var scalarSlices = Swift.split(unicodeScalars, { $0 == separator })
return scalarSlices.map { $0 as String }
}

View File

@@ -119,7 +119,7 @@ testStartsWith()
func testEnumerate() {
println("testing enumerate")
// CHECK: testing enumerate
for (i, s) in enumerate( "You will never retrieve the necronomicon!".split(" ") ) {
for (i, s) in enumerate( "You will never retrieve the necronomicon!"._split(" ") ) {
println("\(i): \(s)")
}
// CHECK-NEXT: 0: You

View File

@@ -12,7 +12,7 @@ func testFindFileAndURL(path: String) {
path, usedEncoding: &usedEncoding, error: &err)
println("error: " + (err ? err.description : "<no error>"))
println("content: " + (content ? content!.lines[0] : "<no content>"))
println("content: " + (content ? content!._lines[0] : "<no content>"))
var url = NSURL.URLWithString("file://" + path)
@@ -21,7 +21,7 @@ func testFindFileAndURL(path: String) {
url, usedEncoding: &usedEncoding, error: &err)
println("error: " + (err ? err.description : "<no error>"))
println("content: " + (content ? content!.lines[0] : "<no content>"))
println("content: " + (content ? content!._lines[0] : "<no content>"))
}

View File

@@ -2,7 +2,7 @@
// CHECK-NOT: Reallocations exceeded 30
func testReallocation() {
var x = "The quick brown fox jumped over the lazy dog\n".split(" ")
var x = "The quick brown fox jumped over the lazy dog\n"._split(" ")
var story = "Let me tell you a story:"
var laps = 1000
@@ -18,7 +18,7 @@ func testReallocation() {
// To avoid dumping a vast string here, just write the first
// part of the story out each time there's a reallocation.
var intro = story.split(":")[0]
var intro = story._split(":")[0]
println("reallocation \(reallocations), with intro \(intro)")
if reallocations >= 30 {