mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 07:19:16 +02:00
TAChart: Fix issue in recently added TCustomSortedChartSource.ItemFind(). Issue #35666, patch by Marcin Wiazowski.
git-svn-id: trunk@61313 -
This commit is contained in:
parent
7c3c2d5094
commit
96442a5bea
@ -1785,20 +1785,21 @@ function TCustomSortedChartSource.ItemFind(AItem: PChartDataItem; L: Integer = 0
|
|||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
if not IsSorted then
|
if L < 0 then
|
||||||
raise ESortError.CreateFmt('%0:s.ItemFind can be called only for sorted source', [ClassName]);
|
L := 0;
|
||||||
|
|
||||||
if R >= FData.Count then
|
if R >= FData.Count then
|
||||||
R := FData.Count - 1;
|
R := FData.Count - 1;
|
||||||
|
|
||||||
// special optimization for adding sorted data at the end
|
// special optimization for adding sorted data at the end
|
||||||
if R >= 0 then
|
if L > R then
|
||||||
if DoCompare(FData.List^[R], AItem) <= 0 then
|
exit(L);
|
||||||
exit(R + 1);
|
if DoCompare(FData.List^[R], AItem) <= 0 then
|
||||||
|
exit(R + 1);
|
||||||
|
|
||||||
|
if not IsSorted then
|
||||||
|
raise ESortError.CreateFmt('%0:s.ItemFind failed, because source is not sorted', [ClassName]);
|
||||||
|
|
||||||
// use binary search
|
// use binary search
|
||||||
if L < 0 then
|
|
||||||
L := 0;
|
|
||||||
while L <= R do
|
while L <= R do
|
||||||
begin
|
begin
|
||||||
I := L + (R - L) div 2;
|
I := L + (R - L) div 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user