class REXML::IOSource

def match( pattern, cons=false )

def match( pattern, cons=false )
  # To avoid performance issue, we need to increase bytes to read per scan
  min_bytes = 1
  while true
    if cons
      md = @scanner.scan(pattern)
    else
      md = @scanner.check(pattern)
    end
    break if md
    return nil if pattern.is_a?(String)
    return nil if @source.nil?
    return nil unless read(nil, min_bytes)
    min_bytes *= 2
  end
  md.nil? ? nil : @scanner
end