소스 검색

clamp _startIndex in trimStart

xuty 4 년 전
부모
커밋
e488abe31e
1개의 변경된 파일1개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      lib/utli/circular_list.dart

+ 1 - 2
lib/utli/circular_list.dart

@@ -128,9 +128,8 @@ class CircularList<T> with ListMixin<T> {
 
   void trimStart(int count) {
     if (count > _length) count = _length;
-
-    // TODO: perhaps bug in original code, this does not clamp the value of startIndex
     _startIndex += count;
+    _startIndex %= _array.length;
     _length -= count;
     onTrimmed?.call(count);
   }