Loading adb/types.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,7 @@ void IOVector::drop_front(IOVector::size_type len) { auto dropped = 0u; auto dropped = 0u; while (dropped < len) { while (dropped < len) { const auto next = chain_[start_index_].size() - begin_offset_; const auto next = chain_[start_index_].size() - begin_offset_; if (dropped + next < len) { if (dropped + next <= len) { pop_front_block(); pop_front_block(); dropped += next; dropped += next; } else { } else { Loading adb/types.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -155,7 +155,7 @@ struct IOVector { return nullptr; return nullptr; } } return chain_.front().data() + begin_offset_; return chain_[start_index_].data() + begin_offset_; } } size_type front_size() const { size_type front_size() const { Loading @@ -163,7 +163,7 @@ struct IOVector { return 0; return 0; } } return chain_.front().size() - begin_offset_; return chain_[start_index_].size() - begin_offset_; } } size_type size() const { return chain_length_ - begin_offset_; } size_type size() const { return chain_length_ - begin_offset_; } Loading adb/types_test.cpp +17 −0 Original line number Original line Diff line number Diff line Loading @@ -117,3 +117,20 @@ TEST(IOVector, misaligned_split) { ASSERT_EQ(1ULL, bc.size()); ASSERT_EQ(1ULL, bc.size()); ASSERT_EQ(create_block("x"), bc.coalesce()); ASSERT_EQ(create_block("x"), bc.coalesce()); } } TEST(IOVector, drop_front) { IOVector vec; vec.append(create_block('x', 2)); vec.append(create_block('y', 1000)); ASSERT_EQ(2U, vec.front_size()); ASSERT_EQ(1002U, vec.size()); vec.drop_front(1); ASSERT_EQ(1U, vec.front_size()); ASSERT_EQ(1001U, vec.size()); vec.drop_front(1); ASSERT_EQ(1000U, vec.front_size()); ASSERT_EQ(1000U, vec.size()); } Loading
adb/types.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,7 @@ void IOVector::drop_front(IOVector::size_type len) { auto dropped = 0u; auto dropped = 0u; while (dropped < len) { while (dropped < len) { const auto next = chain_[start_index_].size() - begin_offset_; const auto next = chain_[start_index_].size() - begin_offset_; if (dropped + next < len) { if (dropped + next <= len) { pop_front_block(); pop_front_block(); dropped += next; dropped += next; } else { } else { Loading
adb/types.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -155,7 +155,7 @@ struct IOVector { return nullptr; return nullptr; } } return chain_.front().data() + begin_offset_; return chain_[start_index_].data() + begin_offset_; } } size_type front_size() const { size_type front_size() const { Loading @@ -163,7 +163,7 @@ struct IOVector { return 0; return 0; } } return chain_.front().size() - begin_offset_; return chain_[start_index_].size() - begin_offset_; } } size_type size() const { return chain_length_ - begin_offset_; } size_type size() const { return chain_length_ - begin_offset_; } Loading
adb/types_test.cpp +17 −0 Original line number Original line Diff line number Diff line Loading @@ -117,3 +117,20 @@ TEST(IOVector, misaligned_split) { ASSERT_EQ(1ULL, bc.size()); ASSERT_EQ(1ULL, bc.size()); ASSERT_EQ(create_block("x"), bc.coalesce()); ASSERT_EQ(create_block("x"), bc.coalesce()); } } TEST(IOVector, drop_front) { IOVector vec; vec.append(create_block('x', 2)); vec.append(create_block('y', 1000)); ASSERT_EQ(2U, vec.front_size()); ASSERT_EQ(1002U, vec.size()); vec.drop_front(1); ASSERT_EQ(1U, vec.front_size()); ASSERT_EQ(1001U, vec.size()); vec.drop_front(1); ASSERT_EQ(1000U, vec.front_size()); ASSERT_EQ(1000U, vec.size()); }