[前][次][番号順一覧][スレッド一覧]

ruby-changes:67621

From: aycabta <ko1@a...>
Date: Mon, 6 Sep 2021 05:24:08 +0900 (JST)
Subject: [ruby-changes:67621] d07060c42a (master): [ruby/reline] No need to use max_by when array.size == 1

https://git.ruby-lang.org/ruby.git/commit/?id=d07060c42a

From d07060c42a7d3fd1ff9a3024e5f064448578a722 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Mon, 6 Sep 2021 04:11:24 +0900
Subject: [ruby/reline] No need to use max_by when array.size == 1

https://github.com/ruby/reline/commit/7e56c8af05
---
 lib/reline/key_stroke.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/reline/key_stroke.rb b/lib/reline/key_stroke.rb
index e097924..3b3f16e 100644
--- a/lib/reline/key_stroke.rb
+++ b/lib/reline/key_stroke.rb
@@ -70,8 +70,8 @@ class Reline::KeyStroke https://github.com/ruby/ruby/blob/trunk/lib/reline/key_stroke.rb#L70
     key_mapping.keys.select { |lhs|
       lhs.start_with? input
     }.tap { |it|
-      return :matched  if it.size == 1 && (it.max_by(&:size)&.== input)
-      return :matching if it.size == 1 && (it.max_by(&:size)&.!= input)
+      return :matched  if it.size == 1 && (it[0] == input)
+      return :matching if it.size == 1 && (it[0] != input)
       return :matched  if it.max_by(&:size)&.size&.< input.size
       return :matching if it.size > 1
     }
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]