Disable robust iteration for ordered dictionaries

This also includes some minor commenting cleanup in that class
This commit is contained in:
Tim Wojtulewicz 2022-09-08 15:37:34 -07:00
parent 57ae03dd7d
commit 20292b0210

View file

@ -1544,6 +1544,10 @@ private:
RobustDictIterator<T> MakeRobustIterator() RobustDictIterator<T> MakeRobustIterator()
{ {
if ( IsOrdered() )
reporter->InternalError(
"RobustIterators are not currently supported for ordered dictionaries");
if ( ! iterators ) if ( ! iterators )
iterators = new std::vector<RobustDictIterator<T>*>; iterators = new std::vector<RobustDictIterator<T>*>;
@ -1552,15 +1556,17 @@ private:
detail::DictEntry<T> GetNextRobustIteration(RobustDictIterator<T>* iter) detail::DictEntry<T> GetNextRobustIteration(RobustDictIterator<T>* iter)
{ {
// If there are any inserted entries, return them first. // If there's no table in the dictionary, then the iterator needs to be
// That keeps the list small and helps avoiding searching // cleaned up because it's not pointing at anything.
// a large list when deleting an entry.
if ( ! table ) if ( ! table )
{ {
iter->Complete(); iter->Complete();
return detail::DictEntry<T>(nullptr); // end of iteration return detail::DictEntry<T>(nullptr); // end of iteration
} }
// If there are any inserted entries, return them first.
// That keeps the list small and helps avoiding searching
// a large list when deleting an entry.
if ( iter->inserted && ! iter->inserted->empty() ) if ( iter->inserted && ! iter->inserted->empty() )
{ {
// Return the last one. Order doesn't matter, // Return the last one. Order doesn't matter,
@ -1570,6 +1576,7 @@ private:
return e; return e;
} }
// First iteration.
if ( iter->next < 0 ) if ( iter->next < 0 )
iter->next = Next(-1); iter->next = Next(-1);