We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 24ade49 + 9998161 commit 2cbe75dCopy full SHA for 2cbe75d
stdlib/public/core/Sequence.swift
@@ -988,7 +988,10 @@ extension Sequence {
988
ringBuffer.append(element)
989
} else {
990
ringBuffer[i] = element
991
- i = (i + 1) % maxLength
+ i += 1
992
+ if i >= maxLength {
993
+ i = 0
994
+ }
995
}
996
997
@@ -1067,7 +1070,10 @@ extension Sequence {
1067
1070
1068
1071
result.append(ringBuffer[i])
1069
1072
- i = (i + 1) % k
1073
1074
+ if i >= k {
1075
1076
1077
1078
1079
return Array(result)
0 commit comments