From 8445618f1d53344f94e38eefe75b9afb75fba3af Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 21 May 2014 20:30:23 +0000 Subject: [PATCH] [stdlib] String API Review: hide "split" and "lines" Swift SVN r18514 --- stdlib/core/StringLegacy.swift | 6 +++--- test/stdlib/Algorithm.swift | 2 +- test/stdlib/NSStringAPI.swift | 4 ++-- test/stdlib/StringReallocation.swift | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/core/StringLegacy.swift b/stdlib/core/StringLegacy.swift index 3155acdd4f5..a2feb390ffd 100644 --- a/stdlib/core/StringLegacy.swift +++ b/stdlib/core/StringLegacy.swift @@ -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 } } diff --git a/test/stdlib/Algorithm.swift b/test/stdlib/Algorithm.swift index e450a44a1e9..478afdf9ae7 100644 --- a/test/stdlib/Algorithm.swift +++ b/test/stdlib/Algorithm.swift @@ -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 diff --git a/test/stdlib/NSStringAPI.swift b/test/stdlib/NSStringAPI.swift index 4a3765e49af..df98275f1b1 100644 --- a/test/stdlib/NSStringAPI.swift +++ b/test/stdlib/NSStringAPI.swift @@ -12,7 +12,7 @@ func testFindFileAndURL(path: String) { path, usedEncoding: &usedEncoding, error: &err) println("error: " + (err ? err.description : "")) - println("content: " + (content ? content!.lines[0] : "")) + println("content: " + (content ? content!._lines[0] : "")) var url = NSURL.URLWithString("file://" + path) @@ -21,7 +21,7 @@ func testFindFileAndURL(path: String) { url, usedEncoding: &usedEncoding, error: &err) println("error: " + (err ? err.description : "")) - println("content: " + (content ? content!.lines[0] : "")) + println("content: " + (content ? content!._lines[0] : "")) } diff --git a/test/stdlib/StringReallocation.swift b/test/stdlib/StringReallocation.swift index 15a456724d5..b327d8c58e9 100644 --- a/test/stdlib/StringReallocation.swift +++ b/test/stdlib/StringReallocation.swift @@ -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 {