Skip to content

Commit

Permalink
Improve gapped series computation by a few milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Nov 29, 2024
1 parent d62312a commit 09347e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gem/lib/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ def series(size: @vars[:size], **_)
series.push(*start...start + size)
# Set first and last pages plus gaps when needed, respecting the size
if vars[:ends] && size >= 7
series[0] = 1 unless series[0] == 1
series[0] = 1
series[1] = :gap unless series[1] == 2
series[-2] = :gap unless series[-2] == @last - 1
series[-1] = @last unless series[-1] == @last
series[-1] = @last
end
end
series[series.index(@page)] = @page.to_s
Expand Down

0 comments on commit 09347e3

Please sign in to comment.