Replace locally implement operator overload for method comparison by already available SameMethod. Proposed by n7800 in MR

This commit is contained in:
wp_xyz 2025-02-02 12:09:48 +01:00
parent 48e844f7f6
commit 4e939b31dd
14 changed files with 51 additions and 59 deletions

View File

@ -301,7 +301,7 @@ type
implementation
uses
LResources, Math, PropEdits,
LResources, Math, LazMethodList, PropEdits,
TAChartStrConsts, TAGeometry, TAMath;
var
@ -1182,14 +1182,14 @@ end;
procedure TChartAxis.SetOnGetMarkText(AValue: TChartGetAxisMarkTextEvent);
begin
if TMethod(FOnGetMarkText) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGetMarkText), TMethod(AValue)) then exit;
FOnGetMarkText := AValue;
StyleChanged(Self);
end;
procedure TChartAxis.SetOnMarkToText(AValue: TChartAxisMarkToTextEvent);
begin
if TMethod(FOnMarkToText) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnMarkToText), TMethod(AValue)) then exit;
FOnMarkToText := AValue;
StyleChanged(Self);
end;

View File

@ -31,7 +31,7 @@ interface
uses
Classes, Controls, SysUtils, Types, Math,
StdCtrls, Graphics, LCLIntf, LCLType, Themes,
StdCtrls, Graphics, LCLIntf, LCLType, LazMethodList, Themes,
IntegerList, LazUTF8,
TAChartUtils, TACustomSeries, TALegend, TAGraph,
TACustomSource, TADrawerCanvas, TADrawUtils, TAEnumerators, TAGeometry;
@ -732,14 +732,14 @@ end;
procedure TChartListbox.SetOnAddSeries(AValue: TChartListboxAddSeriesEvent);
begin
if TMethod(FOnAddSeries) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnAddSeries), TMethod(AValue)) then exit;
FOnAddSeries := AValue;
Populate;
end;
procedure TChartListbox.SetOnPopulate(AValue: TNotifyEvent);
begin
if TMethod(FOnPopulate) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnPopulate), TMethod(AValue)) then exit;
FOnPopulate := AValue;
Populate;
end;

View File

@ -397,8 +397,6 @@ procedure UpdateMinMax(AValue: Integer; var AMin, AMax: Integer); overload;
function WeightedAverage(AX1, AX2, ACoeff: Double): Double; inline;
operator =(const A, B: TMethod): Boolean; overload; inline;
var
DrawData: TDrawDataRegistry;
ShowMessageProc: TShowMessageProc;
@ -407,7 +405,7 @@ var
implementation
uses
StrUtils, TypInfo, TAChartStrConsts;
StrUtils, TypInfo, LazMethodList, TAChartStrConsts;
function BoundsSize(ALeft, ATop: Integer; ASize: TSize): TRect; inline;
begin
@ -682,10 +680,6 @@ begin
Result := AX1 * (1 - ACoeff) + AX2 * ACoeff;
end;
operator = (const A, B: TMethod): Boolean;
begin
Result := (A.Code = B.Code) and (A.Data = B.Data);
end;
{ THistory }
@ -870,7 +864,7 @@ end;
procedure TIntervalList.SetOnChange(AValue: TNotifyEvent);
begin
if TMethod(FOnChange) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnChange), TMethod(AValue)) then exit;
FOnChange := AValue;
end;

View File

@ -370,7 +370,7 @@ type
implementation
uses
Math, PropEdits, StrUtils, LResources, Types, GraphUtil,
Math, PropEdits, StrUtils, LResources, LazMethodList, Types, GraphUtil,
TAChartStrConsts, TAGeometry, TAMath;
function CreateLazIntfImage(
@ -1118,14 +1118,14 @@ end;
procedure TChartSeries.SetOnGetMark(AValue: TChartGetMarkEvent);
begin
if TMethod(FOnGetMark) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGetMark), TMethod(AValue)) then exit;
FOnGetMark := AValue;
UpdateParentChart;
end;
procedure TChartSeries.SetOnGetMarkText(AValue: TChartGetMarkTextEvent);
begin
if TMethod(FOnGetMarkText) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGetMarkText), TMethod(AValue)) then exit;
FOnGetMarkText := AValue;
UpdateParentChart;
end;

View File

@ -82,7 +82,7 @@ procedure Register;
implementation
uses
Math, SysUtils, DateUtils, TAMath;
Math, SysUtils, DateUtils, LazMethodList, TAMath;
type
@ -345,7 +345,7 @@ end;
procedure TDbChartSource.SetOnGetItem(AValue: TDbChartSourceGetItemEvent);
begin
if TMethod(FOnGetItem) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGetItem), TMethod(AValue)) then exit;
FOnGetItem := AValue;
Reset;
end;

View File

@ -499,7 +499,7 @@ implementation
uses
ipf,
GraphType, GraphUtil, Math, spe, StrUtils, SysUtils,
GraphType, GraphUtil, Math, spe, StrUtils, SysUtils, LazMethodList,
TAChartStrConsts, TAGeometry, TAGraph, TAMath;
const
@ -776,7 +776,7 @@ end;
procedure TFuncSeries.SetOnCalculate(AValue: TFuncCalculateEvent);
begin
if TMethod(FOnCalculate) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnCalculate), TMethod(AValue)) then exit;
FOnCalculate := AValue;
UpdateParentChart;
end;
@ -897,7 +897,7 @@ end;
procedure TParametricCurveSeries.SetOnCalculate(
AValue: TParametricCurveCalculateEvent);
begin
if TMethod(FOnCalculate) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnCalculate), TMethod(AValue)) then exit;
FOnCalculate := AValue;
UpdateParentChart;
end;
@ -2879,7 +2879,7 @@ end;
procedure TColorMapSeries.SetOnCalculate(AValue: TFuncCalculate3DEvent);
begin
if TMethod(FOnCalculate) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnCalculate), TMethod(AValue)) then exit;
FOnCalculate := AValue;
InvalidateBufferImage;
UpdateParentChart;

View File

@ -525,7 +525,7 @@ implementation
uses
Math, Types,
Clipbrd, Dialogs, LResources,
Clipbrd, Dialogs, LResources, LazMethodList,
TADrawerCanvas, TAGeometry, TAMath, TAStyles;
const
@ -1835,77 +1835,77 @@ end;
procedure TChart.SetOnAfterDraw(AValue: TChartDrawEvent);
begin
if TMethod(FOnAfterDraw) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnAfterDraw), TMethod(AValue)) then exit;
FOnAfterDraw := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnAfterCustomDrawBackground(AValue: TChartAfterCustomDrawEvent);
begin
if TMethod(FOnAfterCustomDrawBackground) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnAfterCustomDrawBackground), TMethod(AValue)) then exit;
FOnAfterCustomDrawBackground := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnAfterCustomDrawBackWall(AValue: TChartAfterCustomDrawEvent);
begin
if TMethod(FOnAfterCustomDrawBackWall) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnAfterCustomDrawBackWall), TMethod(AValue)) then exit;
FOnAfterCustomDrawBackWall := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnAfterDrawBackground(AValue: TChartAfterDrawEvent);
begin
if TMethod(FOnAfterDrawBackground) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnAfterDrawBackground), TMethod(AValue)) then exit;
FOnAfterDrawBackground := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnAfterDrawBackWall(AValue: TChartAfterDrawEvent);
begin
if TMethod(FOnAfterDrawBackWall) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnAfterDrawBackWall), TMethod(AValue)) then exit;
FOnAfterDrawBackWall := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnBeforeCustomDrawBackground(AValue: TChartBeforeCustomDrawEvent);
begin
if TMethod(FOnBeforeCustomDrawBackground) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnBeforeCustomDrawBackground), TMethod(AValue)) then exit;
FOnBeforeCustomDrawBackground := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnBeforeCustomDrawBackWall(AValue: TChartBeforeCustomDrawEvent);
begin
if TMethod(FOnBeforeCustomDrawBackWall) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnBeforeCustomDrawBackWall), TMethod(AValue)) then exit;
FOnBeforeCustomDrawBackWall := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnBeforeDrawBackground(AValue: TChartBeforeDrawEvent);
begin
if TMethod(FOnBeforeDrawBackground) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnBeforeDrawBackground), TMethod(AValue)) then exit;
FOnBeforeDrawBackground := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnBeforeDrawBackWall(AValue: TChartBeforeDrawEvent);
begin
if TMethod(FOnBeforeDrawBackWall) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnBeforeDrawBackWall), TMethod(AValue)) then exit;
FOnBeforeDrawBackWall := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnChartPaint(AValue: TChartPaintEvent);
begin
if TMethod(FOnChartPaint) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnChartPaint), TMethod(AValue)) then exit;
FOnChartPaint := AValue;
StyleChanged(Self);
end;
procedure TChart.SetOnDrawLegend(AValue: TChartDrawLegendEvent);
begin
if TMethod(FOnDrawLegend) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnDrawLegend), TMethod(AValue)) then exit;
FOnDrawLegend := AValue;
StyleChanged(self);
end;

View File

@ -339,7 +339,7 @@ type
implementation
uses
Math, PropEdits, Types, LResources,
Math, PropEdits, Types, LResources, LazMethodList,
TADrawerCanvas, TAGeometry;
const
@ -1206,14 +1206,14 @@ end;
procedure TChartSeriesLegend.SetOnDraw(AValue: TLegendItemDrawEvent);
begin
if TMethod(FOnDraw) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnDraw), TMethod(AValue)) then exit;
FOnDraw := AValue;
StyleChanged(Self);
end;
procedure TChartSeriesLegend.SetOnCreate(AValue: TLegendItemCreateEvent);
begin
if TMethod(FOnCreate) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnCreate), TMethod(AValue)) then exit;
FOnCreate := AValue;
StyleChanged(Self);
end;

View File

@ -220,7 +220,7 @@ type
implementation
uses
Math,
Math, LazMethodList,
TAChartStrConsts, TATypes, TACustomSource, TAGeometry, TAGraph;
const
@ -901,7 +901,7 @@ end;
procedure TCustomPieSeries.SetOnCustomDrawPie(AValue: TCustomDrawPieEvent);
begin
if TMethod(FOnCustomDrawPie) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnCustomDrawPie), TMethod(AValue)) then exit;
FOnCustomDrawPie := AValue;
UpdateParentChart;
end;

View File

@ -410,7 +410,7 @@ type
implementation
uses
{GraphMath,} GraphType, IntfGraphics, LResources, Math, PropEdits, SysUtils,
GraphType, IntfGraphics, LResources, LazMethodList, Math, PropEdits, SysUtils,
TAChartStrConsts, TADrawerCanvas, TAGeometry, TACustomSource, TAGraph,
TAMath, TAStyles;
@ -1898,14 +1898,14 @@ end;
procedure TBarSeries.SetOnBeforeDrawBar(AValue: TBeforeDrawBarEvent);
begin
if TMethod(FOnBeforeDrawBar) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnBeforeDrawBar), TMethod(AValue)) then exit;
FOnBeforeDrawBar := AValue;
UpdateParentChart;
end;
procedure TBarSeries.SetOnCustomDrawBar(AValue: TCustomDrawBarEvent);
begin
if TMethod(FOnCustomDrawBar) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnCustomDrawBar), TMethod(AValue)) then exit;
FOnCustomDrawBar := AValue;
UpdateParentChart;
end;
@ -2520,14 +2520,14 @@ end;
procedure TUserDrawnSeries.SetOnDraw(AValue: TSeriesDrawEvent);
begin
if TMethod(FOnDraw) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnDraw), TMethod(AValue)) then exit;
FOnDraw := AValue;
UpdateParentChart;
end;
procedure TUserDrawnSeries.SetOnGetBounds(AValue: TSeriesGetBoundsEvent);
begin
if TMethod(FOnGetBounds) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGetBounds), TMethod(AValue)) then exit;
FOnGetBounds := AValue;
UpdateParentChart;
end;

View File

@ -304,7 +304,7 @@ procedure Register;
implementation
uses
Math, StrUtils, SysUtils, TAMath, TAChartStrConsts;
Math, StrUtils, SysUtils, LazMethodList, TAMath, TAChartStrConsts;
type
TCustomChartSourceAccess = class(TCustomChartSource);
@ -1485,7 +1485,7 @@ end;
procedure TUserDefinedChartSource.SetOnGetChartDataItem(
AValue: TGetChartDataItemEvent);
begin
if TMethod(FOnGetChartDataItem) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGetChartDataItem), TMethod(AValue)) then exit;
FOnGetChartDataItem := AValue;
Reset;
end;

View File

@ -15,7 +15,7 @@ unit TATextElements;
interface
uses
Classes, Graphics, Types,
Classes, Graphics, Types, LazMethodList,
TAChartUtils, TADrawUtils, TATypes,
// Workaround for issue #22850.
@ -585,7 +585,7 @@ end;
procedure TChartTextElement.SetOnGetShape(AValue: TChartGetShapeEvent);
begin
if TMethod(FOnGetShape) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGetShape), TMethod(AValue)) then exit;
FOnGetShape := AValue;
StyleChanged(Self);
end;

View File

@ -202,7 +202,7 @@ type
implementation
uses
ComponentEditors, Forms, Math, PropEdits,
ComponentEditors, Forms, Math, LazMethodList, PropEdits,
TAChartStrConsts, TAMath, TASubcomponentsEditor;
type
@ -797,14 +797,14 @@ end;
procedure TUserDefinedAxisTransform.SetOnAxisToGraph(AValue: TTransformEvent);
begin
if TMethod(FOnAxisToGraph) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnAxisToGraph), TMethod(AValue)) then exit;
FOnAxisToGraph := AValue;
Changed;
end;
procedure TUserDefinedAxisTransform.SetOnGraphToAxis(AValue: TTransformEvent);
begin
if TMethod(FOnGraphToAxis) = TMethod(AValue) then exit;
if SameMethod(TMethod(FOnGraphToAxis), TMethod(AValue)) then exit;
FOnGraphToAxis := AValue;
Changed;
end;

View File

@ -422,7 +422,8 @@ procedure Register;
implementation
uses WSShellCtrls
uses
WSShellCtrls, LazMethodList
{$ifdef windows}
,Windows, ShellApi
{$endif};
@ -465,10 +466,6 @@ begin
Result := Format(sShellCtrlsGB, [Format('%.1n', [AFileSize / ONE_GB])]);
end;
operator = (const A, B: TMethod): Boolean;
begin
Result := (A.Code = B.Code) and (A.Data = B.Data);
end;
{ TShellListItem }
@ -701,7 +698,7 @@ var
RootNode: TTreeNode;
CurrPath: String;
begin
if TMethod(AValue) = TMethod(FOnSortCompare) then
if SameMethod(TMethod(AValue), TMethod(FOnSortCompare)) then
Exit;
FOnSortCompare := AValue;
@ -1776,7 +1773,8 @@ end;
procedure TCustomShellListView.SetOnSortCompare(AValue: TFileItemCompareEvent);
begin
if TMethod(AValue) = TMethod(FOnSortCompare) then Exit;
if SameMethod(TMethod(AValue), TMethod(FOnSortCompare)) then
Exit;
FOnSortCompare:=AValue;
Clear;
Items.Clear;