Skip to content
Permalink
Browse files

Prefer inline code over outsourced one-time used function BestTableName

  • Loading branch information...
ansgarbecker committed Jul 23, 2019
1 parent d76aacb commit 676f4b1e74c6fab26212968ec5bc272c0e9f2c71
Showing with 6 additions and 14 deletions.
  1. +1 −13 source/apphelpers.pas
  2. +5 −1 source/exportgrid.pas
@@ -14,7 +14,7 @@ interface
Registry, DateUtils, Generics.Collections, StrUtils, AnsiStrings, TlHelp32, Types,
dbconnection, dbstructures, SynMemo, Menus, WinInet, gnugettext, Themes,
Character, ImgList, System.UITypes, ActnList, WinSock, IOUtils, StdCtrls, ComCtrls,
CommCtrl, Vcl.Imaging.pngimage;
CommCtrl;

type

@@ -265,7 +265,6 @@ TAppSettings = class(TObject)
function encrypt(str: String): String;
function decrypt(str: String): String;
function HTMLSpecialChars(str: String): String;
function BestTableName(Data: TDBQuery): String;
function EncodeURLParam(const Value: String): String;
procedure StreamWrite(S: TStream; Text: String = '');
function _GetFileSize(Filename: String): Int64;
@@ -518,17 +517,6 @@ function HTMLSpecialChars(str: String) : String;
end;


function BestTableName(Data: TDBQuery): String;
begin
// Get table name from result if possible. Used by GridToXYZ() functions.
try
Result := Data.TableName;
except
Result := _('UnknownTable');
end;
end;


function EncodeURLParam(const Value: String): String;
var
c: Char;
@@ -543,7 +543,11 @@ procedure TfrmExportGrid.btnOKClick(Sender: TObject);
else
NodeCount := Grid.RootNodeCount;
MainForm.EnableProgress(NodeCount);
TableName := BestTableName(GridData);
try
TableName := GridData.TableName;
except
TableName := _('UnknownTable');
end;
ExcludeCol := NoColumn;
if (not chkIncludeAutoIncrement.Checked) or (not chkIncludeAutoIncrement.Enabled) then
ExcludeCol := GridData.AutoIncrementColumn;

0 comments on commit 676f4b1

Please sign in to comment.
You can’t perform that action at this time.