Skip to content

Commit a1fb6f1

Browse files
committed
[stdlib] Gardening: ringBuffer position index
1 parent bbfc064 commit a1fb6f1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

stdlib/public/core/Sequence.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,7 @@ extension Sequence {
906906
ringBuffer.append(element)
907907
} else {
908908
ringBuffer[i] = element
909-
i += 1
910-
i %= maxLength
909+
i = (i + 1) % maxLength
911910
}
912911
}
913912

@@ -986,8 +985,7 @@ extension Sequence {
986985
} else {
987986
result.append(ringBuffer[i])
988987
ringBuffer[i] = element
989-
i += 1
990-
i %= k
988+
i = (i + 1) % k
991989
}
992990
}
993991
return result

0 commit comments

Comments
 (0)