From 36f5e19e33added8f1f5eefcf54ea76735822dd3 Mon Sep 17 00:00:00 2001 From: Jay Zhuang Date: Fri, 28 Oct 2022 14:24:48 -0700 Subject: [PATCH] Fix a Windows build error (#10897) Summary: The for loop is marked as unreachable code because it will never call the increment. Switch it to `if`. ``` \table\merging_iterator.cc(823): error C2220: the following warning is treated as an error \table\merging_iterator.cc(823): warning C4702: unreachable code \table\merging_iterator.cc(1030): error C2220: the following warning is treated as an error \table\merging_iterator.cc(1030): warning C4702: unreachable code ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10897 Reviewed By: cbi42 Differential Revision: D40811790 Pulled By: jay-zhuang fbshipit-source-id: fe8fd3e7cf3d6f710360c402b79763854d5120df --- table/merging_iterator.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/table/merging_iterator.cc b/table/merging_iterator.cc index e681860e5..7300a630a 100644 --- a/table/merging_iterator.cc +++ b/table/merging_iterator.cc @@ -820,7 +820,8 @@ bool MergingIterator::SkipNextDeleted() { // Point key case: check active_ for range tombstone coverage. ParsedInternalKey pik; ParseInternalKey(current->iter.key(), &pik, false).PermitUncheckedError(); - for (auto& i : active_) { + if (!active_.empty()) { + auto i = *active_.begin(); if (i < current->level) { // range tombstone is from a newer level, definitely covers assert(comparator_->Compare(range_tombstone_iters_[i]->start_key(), @@ -1027,7 +1028,8 @@ bool MergingIterator::SkipPrevDeleted() { // Point key case: check active_ for range tombstone coverage. ParsedInternalKey pik; ParseInternalKey(current->iter.key(), &pik, false).PermitUncheckedError(); - for (auto& i : active_) { + if (!active_.empty()) { + auto i = *active_.begin(); if (i < current->level) { // range tombstone is from a newer level, definitely covers assert(comparator_->Compare(range_tombstone_iters_[i]->start_key(), @@ -1066,6 +1068,7 @@ bool MergingIterator::SkipPrevDeleted() { return false /* current key not deleted */; } } + assert(active_.empty()); assert(maxHeap_->top()->type == HeapItem::ITERATOR); return false /* current key not deleted */;