Skip to content

Commit 9f325e4

Browse files
committed
Lazy-require set and tmpdir to avoid polluting Ruby 2.7 ancestors
Top-level require of 'set' and 'tmpdir' caused additional modules to be loaded at startup, shifting the Integer ancestor count on Ruby 2.7 and breaking DAP protocol hover tests. Replace Set with plain Hash in reconcile_breakpoints and lazy-require tmpdir in ensure_wk_lock!.
1 parent bbf30bc commit 9f325e4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/debug/session.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242

4343
require 'json' if ENV['RUBY_DEBUG_TEST_UI'] == 'terminal'
4444
require 'pp'
45-
require 'set'
46-
require 'tmpdir'
4745

4846
class RubyVM::InstructionSequence
4947
def traceable_lines_norec lines
@@ -113,19 +111,19 @@ def serialize_sync_breakpoints
113111
end
114112

115113
def reconcile_breakpoints(specs)
116-
remote_keys = Set.new
114+
remote_keys = {}
117115

118116
specs.each do |spec|
119117
key = bp_key_from_spec(spec)
120118
next unless key
121-
remote_keys << key
119+
remote_keys[key] = true
122120
unless @bps.key?(key)
123121
create_bp_from_spec(spec)
124122
end
125123
end
126124

127125
@bps.delete_if do |key, bp|
128-
if syncable_bp?(bp) && !remote_keys.include?(key)
126+
if syncable_bp?(bp) && !remote_keys.key?(key)
129127
bp.delete
130128
true
131129
end
@@ -2163,6 +2161,7 @@ def unlock_wk_lock
21632161

21642162
private def ensure_wk_lock!
21652163
return if @wk_lock_file
2164+
require 'tmpdir'
21662165
path = File.join(Dir.tmpdir, "ruby-debug-#{Process.uid}-pgrp-#{Process.getpgrp}.lock")
21672166
@wk_lock_file = File.open(path, File::WRONLY | File::CREAT, 0600)
21682167
rescue SystemCallError => e

0 commit comments

Comments
 (0)