Hello, I have fixed the function as below (providing for the sake of completeness):
function seekIndexToInsertForSortedStringList(stringList: TStringList; stringToAdd: String; caseinsensitive: boolean) : Integer; var low, mid, high: integer; begin if(stringList.Count = 0) then begin Result := 0; Exit; end; low := 0; high := stringList.Count - 1; if(caseinsensitive) then begin if(AnsiCompareStr(stringList.Strings[low], stringToAdd) > 0) then result := 0 else if(AnsiCompareStr(stringList.Strings[high], stringToAdd) < 0) then result := high + 1 else begin while(low < high) do begin mid := low + ((high - low) div 2); // Let's say the string list is 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 // if want to add 1.5 { low = 0, high = 5, 1. mid = 2, stringList.Strings[mid] = 3.0 low = 0, high = 2 2. mid = 1, stringList.Strings[mid] = 2.0 low = 0, high = 1 3. mid = 0, stringList.Strings[mid] = 1.0 low = 1, high = 1 --> EXIT LOOP } if(AnsiCompareStr(stringList.Strings[mid], stringToAdd) < 0) then low := mid + 1 else // can't be high = mid-1: here A[mid] >= value, // so high can't be < mid if A[mid] == value high := mid; end; result := low end; end else begin if(stringList.Strings[low] > stringToAdd) then result := 0 else if(stringList.Strings[high] < stringToAdd) then result := high + 1 else begin while(low < high) do begin mid := low + ((high - low) div 2); if(stringList.Strings[mid] < stringToAdd) then low := mid + 1 else // can't be high = mid-1: here A[mid] >= value, // so high can't be < mid if A[mid] == value high := mid; end; result := low end; end; end; You can really feel the SPEED on pages from cache with lots of objects! :-) Regards, SZ On Tue, Dec 7, 2010 at 3:41 PM, Anton S. <an...@rambler.ru> wrote: > Arno wrote: > >I don't think so, why should it? > > Well, the connection to HTTP client is closed when response is sent > (usually; there are some options in the request header to keep it but these > cases are rarer). > I'm just supposing, not asserting. > > -- > Anton > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be