Skip to content

Commit d596fd8

Browse files
committed
GC.stat(x) should always be the same as GC.stat[x]
1 parent f8b4abf commit d596fd8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

spec/ruby/core/gc/stat_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
GC.stat(:count).should be_kind_of(Integer)
1212
end
1313

14+
it "returns nil for a non-existent stat" do
15+
GC.stat(:does_not_exist).should be_nil
16+
end
17+
1418
it "increases count after GC is run" do
1519
count = GC.stat(:count)
1620
GC.start

src/main/ruby/truffleruby/core/gc.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ def self.stat(option = nil)
130130
end
131131
end
132132

133-
return stat unless option
134-
135-
if stat[option]
133+
if option
136134
stat[option]
137135
else
138-
0
136+
stat
139137
end
140138
end
141139

0 commit comments

Comments
 (0)