ruby-changes:67010
From: Jeremy <ko1@a...>
Date: Sat, 31 Jul 2021 21:27:31 +0900 (JST)
Subject: [ruby-changes:67010] 2a7235421f (ruby_2_7): Fix SortedSet not being sorted the first time when rbtree is used
https://git.ruby-lang.org/ruby.git/commit/?id=2a7235421f From 2a7235421fcd59b449c84306d059f22b4c5f0865 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Thu, 29 Apr 2021 11:58:12 -0700 Subject: Fix SortedSet not being sorted the first time when rbtree is used Fixes [Bug #17841] --- lib/set.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/set.rb b/lib/set.rb index 5a96c81..1b0e3ae 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -691,6 +691,7 @@ class SortedSet < Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L691 def setup # :nodoc: @@setup and return + ret = nil @@mutex.synchronize do # a hack to shut up warning @@ -698,6 +699,7 @@ class SortedSet < Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L699 begin require 'rbtree' + ret = :rbtree module_eval <<-END, __FILE__, __LINE__+1 def initialize(*args) @@ -712,6 +714,7 @@ class SortedSet < Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L714 alias << add END rescue LoadError + ret = true module_eval <<-END, __FILE__, __LINE__+1 def initialize(*args) @keys = nil @@ -788,13 +791,17 @@ class SortedSet < Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L791 remove_method :old_init @@setup = true + ret end end end def initialize(*args, &block) # :nodoc: - SortedSet.setup - @keys = nil + if SortedSet.setup == :rbtree + @hash = RBTree.new + else + @keys = nil + end super end end -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/