Skip to content

Commit a8a4010

Browse files
committed
Add slices.Backward
1 parent ebb272a commit a8a4010

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

annot.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,10 @@ func Write(w io.Writer, annots ...*Annot) error {
131131
a.createLines()
132132
}
133133

134-
// Start with second last annotation index and decrement.
135-
// The last annotation will always be on row=0 and needs
136-
// no adjustment.
137-
for aIdxDecr := len(annots) - 2; 0 <= aIdxDecr; aIdxDecr-- {
138-
setRow(annots[aIdxDecr], annots[aIdxDecr+1:])
134+
// Start with second last annotation index. The last annotation
135+
// will always be on row=0 and needs no adjustment.
136+
for aIdx := range slices.Backward(annots[:len(annots)-1]) {
137+
setRow(annots[aIdx], annots[aIdx+1:])
139138
}
140139

141140
return write(w, annots)

0 commit comments

Comments
 (0)