From 449869ccae70ae422da99ba4fedb821c168fd74c Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Sun, 6 Mar 2016 02:46:21 -0800 Subject: [PATCH] stdlib: Remove dead code in String and UnicodeScalar --- stdlib/public/core/StringLegacy.swift | 35 -------------------- stdlib/public/core/UnicodeScalar.swift | 44 -------------------------- 2 files changed, 79 deletions(-) diff --git a/stdlib/public/core/StringLegacy.swift b/stdlib/public/core/StringLegacy.swift index 2db97ce2681..4f9b99f8efd 100644 --- a/stdlib/public/core/StringLegacy.swift +++ b/stdlib/public/core/StringLegacy.swift @@ -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.. Bool) -> [String] { - let scalarSlices = unicodeScalars.split(isSeparator: predicate) - return scalarSlices.map { String($0) } - } } diff --git a/stdlib/public/core/UnicodeScalar.swift b/stdlib/public/core/UnicodeScalar.swift index 621eda61cf5..108c7afd532 100644 --- a/stdlib/public/core/UnicodeScalar.swift +++ b/stdlib/public/core/UnicodeScalar.swift @@ -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 {