   public var uppercaseString: String {
     if self._core.isASCII {
       let length = self._core.count
-      let string = self._core.startASCII
+      let source = self._core.startASCII
       var buffer = _StringBuffer(
         capacity: length, initialSize: length, elementWidth: 1)
-      var pointer = UnsafeMutablePointer<UInt8>(buffer.start)
+      var dest = UnsafeMutablePointer<UInt8>(buffer.start)
       for i in 0..<length {
-        switch string[i] {
-        case let x where (x >= 0x61 && x <= 0x7a):
-          pointer[i] = x &- 0x20
-        case let x:
-          pointer[i] = x
-        }
+        // See the comment above in lowercaseString.
+        let value = source[i]
+        let isLower =
+          _asciiLowerCaseTable >>
+          UInt64(((value &- 1) & 0b0111_1111) >> 1)
+        let add = (isLower & 0x1) << 5
+        dest[i] = value - UInt8(add)
       }
       return String(_storage: buffer)
     }

// FIXME: these properties should be implemented in the core library.
// <rdar://problem/17550602> [unicode] Implement case folding
extension String {
  public var lowercaseString: String {
    if self._core.isASCII {
      let length = self._core.count
      let string = self._core.startASCII
      var buffer = _StringBuffer(
        capacity: length, initialSize: length, elementWidth: 1)
      var pointer = UnsafeMutablePointer<UInt8>(buffer.start)
      for i in 0..<length {
        switch string[i] {
        case let x where (x >= 0x41 && x <= 0x5a):
          pointer[i] = x &+ 0x20
        case let x:
          pointer[i] = x
        }
      }
      return String(_storage: buffer)
    }

    return _ns.uppercaseString
  }
}
