From 09347e3c5db0e5a21b8ab3055fd7f204f9a33dda Mon Sep 17 00:00:00 2001
From: Domizio Demichelis
Date: Wed, 27 Nov 2024 06:41:56 +0700
Subject: [PATCH] Improve gapped series computation by a few milliseconds
---
gem/lib/pagy.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gem/lib/pagy.rb b/gem/lib/pagy.rb
index fdf228c55..593872d0e 100644
--- a/gem/lib/pagy.rb
+++ b/gem/lib/pagy.rb
@@ -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