Use guard clause, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6084#note_14754681
This commit is contained in:
parent
1e49a8bc6c
commit
d2cfcb3ec1
|
@ -132,18 +132,16 @@ module Gitlab
|
|||
end
|
||||
|
||||
def process_periods(periods)
|
||||
if periods.empty?
|
||||
periods
|
||||
else
|
||||
periods.drop(1).inject([periods.first]) do |result, current|
|
||||
merged = try_merge_period(result.last, current)
|
||||
return periods if periods.empty?
|
||||
|
||||
if merged
|
||||
result[-1] = merged
|
||||
result
|
||||
else
|
||||
result << current
|
||||
end
|
||||
periods.drop(1).inject([periods.first]) do |result, current|
|
||||
merged = try_merge_period(result.last, current)
|
||||
|
||||
if merged
|
||||
result[-1] = merged
|
||||
result
|
||||
else
|
||||
result << current
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue