mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[stdlib] String API Review: hide "split" and "lines"
Swift SVN r18514
This commit is contained in:
@@ -41,11 +41,11 @@ extension String {
|
|||||||
input: Repeat(count: count, repeatedValue: c.value))
|
input: Repeat(count: count, repeatedValue: c.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
var lines : String[] {
|
var _lines : String[] {
|
||||||
return split("\n")
|
return _split("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func split(separator: UnicodeScalar) -> String[] {
|
func _split(separator: UnicodeScalar) -> String[] {
|
||||||
var scalarSlices = Swift.split(unicodeScalars, { $0 == separator })
|
var scalarSlices = Swift.split(unicodeScalars, { $0 == separator })
|
||||||
return scalarSlices.map { $0 as String }
|
return scalarSlices.map { $0 as String }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ testStartsWith()
|
|||||||
func testEnumerate() {
|
func testEnumerate() {
|
||||||
println("testing enumerate")
|
println("testing enumerate")
|
||||||
// CHECK: 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)")
|
println("\(i): \(s)")
|
||||||
}
|
}
|
||||||
// CHECK-NEXT: 0: You
|
// CHECK-NEXT: 0: You
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func testFindFileAndURL(path: String) {
|
|||||||
path, usedEncoding: &usedEncoding, error: &err)
|
path, usedEncoding: &usedEncoding, error: &err)
|
||||||
|
|
||||||
println("error: " + (err ? err.description : "<no error>"))
|
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)
|
var url = NSURL.URLWithString("file://" + path)
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ func testFindFileAndURL(path: String) {
|
|||||||
url, usedEncoding: &usedEncoding, error: &err)
|
url, usedEncoding: &usedEncoding, error: &err)
|
||||||
|
|
||||||
println("error: " + (err ? err.description : "<no error>"))
|
println("error: " + (err ? err.description : "<no error>"))
|
||||||
println("content: " + (content ? content!.lines[0] : "<no content>"))
|
println("content: " + (content ? content!._lines[0] : "<no content>"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// CHECK-NOT: Reallocations exceeded 30
|
// CHECK-NOT: Reallocations exceeded 30
|
||||||
func testReallocation() {
|
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 story = "Let me tell you a story:"
|
||||||
var laps = 1000
|
var laps = 1000
|
||||||
@@ -18,7 +18,7 @@ func testReallocation() {
|
|||||||
|
|
||||||
// To avoid dumping a vast string here, just write the first
|
// To avoid dumping a vast string here, just write the first
|
||||||
// part of the story out each time there's a reallocation.
|
// 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)")
|
println("reallocation \(reallocations), with intro \(intro)")
|
||||||
|
|
||||||
if reallocations >= 30 {
|
if reallocations >= 30 {
|
||||||
|
|||||||
Reference in New Issue
Block a user