[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#79029] Re: ruby/spec needs help from CRuby committers
— Benoit Daloze <eregontp@...>
2017/01/09
Thank you Shyouhei-san for your reply.
[ruby-core:78768] [Ruby trunk Bug#13000] Implement Set#include? with Hash#include?
From:
knu@...
Date:
2016-12-21 08:11:01 UTC
List:
ruby-core #78768
Issue #13000 has been updated by Akinori MUSHA. It originally used Hash#include?, but changed to use Hash#[] to benefit from the optimized dispatch VM instruction for [] (opt_aref). ([Misc #10754]) Running a benchmark, I can observe that Hash#[] actually has an advantage over include? in performance (up to ~1.2x faster) but the "optimization" may only apply to CRuby. Do you think we should have a straightforward implementation for a library shared between Ruby implementations, or is it OK to leave this if I add a comment to explain why? ---------------------------------------- Bug #13000: Implement Set#include? with Hash#include? https://bugs.ruby-lang.org/issues/13000#change-62170 * Author: Charles Nutter * Status: Assigned * Priority: Normal * Assignee: Akinori MUSHA * Target version: * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Why does `Set#include?` not call `Hash#include?`? Currently it calls `Hash#[]`. The protocol of Set already use `Hash#include?` for `==`. ```diff diff --git a/lib/set.rb b/lib/set.rb index 43c388c..f3dbe2d 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -230,7 +230,7 @@ def flatten! # # See also Enumerable#include? def include?(o) - @hash[o] + @hash.include?(o) end alias member? include? ``` -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>