diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2006-05-14 07:21:09 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2006-05-14 07:21:09 +0000 |
| commit | 8991873658747287b86eb477442508a9a3014e5f (patch) | |
| tree | 930415ee0e7652f1b5d4c1c43b8b827653a51b80 /src/document-subset.cpp | |
| parent | Fixing hash sort for null (diff) | |
| download | inkscape-8991873658747287b86eb477442508a9a3014e5f.tar.gz inkscape-8991873658747287b86eb477442508a9a3014e5f.zip | |
Corrected base structure and avoiding infinite loop.
(bzr r833)
Diffstat (limited to 'src/document-subset.cpp')
| -rw-r--r-- | src/document-subset.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/document-subset.cpp b/src/document-subset.cpp index 217176f4e..4e7e9f694 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -57,17 +57,32 @@ struct DocumentSubset::Relations : public GC::Managed<GC::ATOMIC>, } else { Siblings::const_iterator first=children.begin(); Siblings::const_iterator last=children.end() - 1; - while ( first != last ) { - Siblings::const_iterator mid=first + ( last - first + 1 ) / 2; - int pos=sp_object_compare_position(*mid, obj); + if ( children.size() == 1 ) { + int pos = sp_object_compare_position(*first, obj); if ( pos < 0 ) { - first = mid; + // All good. } else if ( pos > 0 ) { - last = mid; + last++; } else { g_assert_not_reached(); } + } else { + while ( first != last ) { + Siblings::const_iterator mid=first + ( last - first + 1 ) / 2; + int pos=sp_object_compare_position(*mid, obj); + if ( pos < 0 ) { + first = mid; + } else if ( pos > 0 ) { + if ( last == mid ) { + break; + } + last = mid; + } else { + g_assert_not_reached(); + } + } } + return last - children.begin(); } } |
