stdlib: Remove dead code in String and UnicodeScalar

This commit is contained in:
Dmitri Gribenko
2016-03-06 02:46:21 -08:00
parent 90ce8daf0b
commit 449869ccae
2 changed files with 0 additions and 79 deletions

View File

@@ -52,22 +52,6 @@ extension String {
public init(_ _c: UnicodeScalar) {
self = String(count: 1, repeatedValue: _c)
}
@warn_unused_result
func _isAll(@noescape predicate: (UnicodeScalar) -> Bool) -> Bool {
for c in unicodeScalars { if !predicate(c) { return false } }
return true
}
@warn_unused_result
func _isAlpha() -> Bool { return _isAll({ $0._isAlpha() }) }
@warn_unused_result
func _isDigit() -> Bool { return _isAll({ $0._isDigit() }) }
@warn_unused_result
func _isSpace() -> Bool { return _isAll({ $0._isSpace() }) }
}
#if _runtime(_ObjC)
@@ -152,17 +136,6 @@ extension String {
}
extension String {
/// Produce a substring of the given string from the given character
/// index to the end of the string.
func _substr(start: Int) -> String {
let rng = unicodeScalars
var startIndex = rng.startIndex
for _ in 0..<start {
startIndex._successorInPlace()
}
return String(rng[startIndex..<rng.endIndex])
}
/// Split the given string at the given delimiter character, returning the
/// strings before and after that character (neither includes the character
/// found) and a boolean value indicating whether the delimiter was found.
@@ -198,12 +171,4 @@ extension String {
}
return (self, "🎃", String(), false)
}
/// Split the given string at each occurrence of a character for which
/// the given predicate evaluates true, returning an array of strings that
/// before/between/after those delimiters.
func _splitIf(predicate: (UnicodeScalar) -> Bool) -> [String] {
let scalarSlices = unicodeScalars.split(isSeparator: predicate)
return scalarSlices.map { String($0) }
}
}

View File

@@ -149,56 +149,12 @@ public struct UnicodeScalar :
return value <= 127
}
// FIXME: Locales make this interesting
@warn_unused_result
func _isAlpha() -> Bool {
return (self >= "A" && self <= "Z") || (self >= "a" && self <= "z")
}
// FIXME: Is there a similar term of art in Unicode?
@warn_unused_result
public func _isASCIIDigit() -> Bool {
return self >= "0" && self <= "9"
}
// FIXME: Unicode makes this interesting
@warn_unused_result
func _isDigit() -> Bool {
return _isASCIIDigit()
}
// FIXME: Unicode and locales make this interesting
var _uppercase: UnicodeScalar {
if self >= "a" && self <= "z" {
return UnicodeScalar(UInt32(self) &- 32)
} else if self >= "à" && self <= "þ" && self != "÷" {
return UnicodeScalar(UInt32(self) &- 32)
}
return self
}
// FIXME: Unicode and locales make this interesting
var _lowercase: UnicodeScalar {
if self >= "A" && self <= "Z" {
return UnicodeScalar(UInt32(self) &+ 32)
} else if self >= "À" && self <= "Þ" && self != "×" {
return UnicodeScalar(UInt32(self) &+ 32)
}
return self
}
// FIXME: Unicode makes this interesting.
@warn_unused_result
public // @testable
func _isSpace() -> Bool {
// FIXME: The constraint-based type checker goes painfully exponential
// when we turn this into one large expression. Break it up for now,
// until we can optimize the constraint solver better.
if self == " " || self == "\t" { return true }
if self == "\n" || self == "\r" { return true }
return self == "\u{0B}" || self == "\u{0C}"
}
// FIXME: Unicode makes this interesting.
@warn_unused_result
func _isPrintableASCII() -> Bool {