aboutsummaryrefslogtreecommitdiffstats
path: root/lib/iterator
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-10-20 16:43:43 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-27 22:44:39 +0200
commit88afe7bb4a7425fbce767a64ed454151514fa4f2 (patch)
treee2861de5f829a49209e0273367625f29cdaf9bc2 /lib/iterator
parent206665a2d97106722a6b32e24a504863040ca515 (diff)
downloadaerc-88afe7bb4a7425fbce767a64ed454151514fa4f2.tar.gz
store: implement the simplified index handling
Simplify the index handling for moving to the next or previous message. Same for moving to the next or previous search results. Moving of the index variable relies on the iterator package's StartIndex and EndIndex functions. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/iterator')
-rw-r--r--lib/iterator/index.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/iterator/index.go b/lib/iterator/index.go
index dd660052..5dad4fe4 100644
--- a/lib/iterator/index.go
+++ b/lib/iterator/index.go
@@ -21,6 +21,9 @@ func FixBounds(i, lower, upper int) int {
// WrapBounds will wrap the index i around its upper- or lower-bound if
// out-of-bound
func WrapBounds(i, lower, upper int) int {
+ if upper <= 0 {
+ return lower
+ }
switch {
case i > upper:
i = lower + (i-upper-1)%upper