ruby-changes:66601
From: Samuel <ko1@a...>
Date: Fri, 25 Jun 2021 17:42:33 +0900 (JST)
Subject: [ruby-changes:66601] e788481843 (master): [ruby/reline] Avoid using blocking `IO.select`.
https://git.ruby-lang.org/ruby.git/commit/?id=e788481843 From e788481843d71030bd5dfee28fd0fc22dcae2f97 Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Wed, 23 Jun 2021 19:44:46 +1200 Subject: [ruby/reline] Avoid using blocking `IO.select`. https://github.com/ruby/reline/commit/de94746393 --- lib/reline/ansi.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index bbb0623..c7c74cc 100644 --- a/lib/reline/ansi.rb +++ b/lib/reline/ansi.rb @@ -183,12 +183,7 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L183 unless @@buf.empty? return false end - rs, = IO.select([@@input], [], [], 0.00001) - if rs and rs[0] - false - else - true - end + !@@input.wait_readable(0) end def self.ungetc(c) @@ -197,8 +192,7 @@ class Reline::ANSI https://github.com/ruby/ruby/blob/trunk/lib/reline/ansi.rb#L192 def self.retrieve_keybuffer begin - result = select([@@input], [], [], 0.001) - return if result.nil? + return unless @@input.wait_readable(0.001) str = @@input.read_nonblock(1024) str.bytes.each do |c| @@buf.push(c) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/