Browse Source

* handle collections with 0 or 1 element better

git-svn-id: trunk@4459 -
florian 19 years ago
parent
commit
9766a9c14a
1 changed files with 3 additions and 0 deletions
  1. 3 0
      rtl/inc/objects.pp

+ 3 - 0
rtl/inc/objects.pp

@@ -2221,6 +2221,9 @@ BEGIN
    Search := False;                                   { Preset failure }
    Search := False;                                   { Preset failure }
    L := 0;                                            { Start count }
    L := 0;                                            { Start count }
    H := Count - 1;                                    { End count }
    H := Count - 1;                                    { End count }
+   Index := 0;
+   if H<=0 then
+     exit;
    While (L <= H) Do Begin
    While (L <= H) Do Begin
      I := (L + H) SHR 1;                              { Mid point }
      I := (L + H) SHR 1;                              { Mid point }
      C := Compare(KeyOf(Items^[I]), Key);             { Compare with key }
      C := Compare(KeyOf(Items^[I]), Key);             { Compare with key }