     // The first byte to read is located at MSB of `_decodeLookahead`.  Get a
     // representation of the buffer where we can read bytes starting from LSB.
     var buffer = _decodeLookahead.byteSwapped
-    if _slowPath(!UTF8._isValidUTF8(buffer, validBytes: _lookaheadFlags)) {
+    if _slowPath(!UTF8._isValidUTF8(buffer)) {
       // The code unit sequence is ill-formed.  According to Unicode
       // recommendation, replace the maximal subpart of ill-formed sequence
       // with one replacement character.

  var _lookaheadFlags: UInt8 = 0


  /// Returns `true` if the LSB bytes in `buffer` are well-formed UTF-8 code		
  /// unit sequence.
  @warn_unused_result
  static func _isValidUTF8(buffer: UInt32, validBytes: UInt8) -> Bool {
    _sanityCheck(validBytes & 0b0000_1111 != 0,
        "input buffer should not be empty")

    if _fastPath(buffer & 0x80 == 0) {
      return true // 0x00 -- 0x7f: 1-byte sequences (ASCII).

    let bit0 = (lut0 >> index) & 1
    let bit1 = (lut1 >> index) & 1

    switch (bit1, bit0) {
    case (0, 0): // 2-byte sequence.
      // Require 10xx xxxx  110x xxxx.
