Skip to content

Skip empty GC information - #4

Merged
ryukobayashi merged 1 commit into
ryukobayashi:masterfrom
okumin:skip-empty-gc
Nov 20, 2024
Merged

ryukobayashi merged 1 commit into
ryukobayashi:masterfrom
okumin:skip-empty-gc

Conversation

@okumin

@okumin okumin commented Nov 20, 2024

Copy link
Copy Markdown
Contributor

In our environment, LastGcInfo is typically empty as the list retains entries where no GC has happened. The current implementation of gc method returns nil in that case.

This is a demo.

irb(main):017:0> def mofu(arr)
irb(main):018:1>   result = arr.map { |x|
irb(main):019:2*     return nil if x.nil?
irb(main):020:2>     x + 1
irb(main):021:2>   }
irb(main):022:1> end
=> :mofu
irb(main):023:0> mofu([1, 2, 3])
=> [2, 3, 4]
irb(main):024:0> mofu([1, nil, 3])
=> nil

The new information should return the elements of valid entries.

irb(main):043:0> def mofu(arr)
irb(main):044:1>   arr.reject { |x| x.nil? }.map { |x|
irb(main):045:2*     x + 1
irb(main):046:2>   }
irb(main):047:1> end
=> :mofu
irb(main):048:0> mofu([1, 2, 3])
=> [2, 3, 4]
irb(main):049:0> mofu([1, nil, 3])
=> [2, 4]

@ryukobayashi
ryukobayashi merged commit 8b7178a into ryukobayashi:master Nov 20, 2024
@okumin
okumin deleted the skip-empty-gc branch November 20, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants