I had to look at the source code ODAC to understand what crash my application and I noticed a lot of places where the code can be more optimal.
For example:
1) Use the keyword CONST for parameters of type String.
Gives a gain in resources, as well as good / right style.
2) Change Length (String_Variable)> 0 on String_Variable <>'' and
Length (String_Variable) = 0 on String_Variable =''
gives a decent win, because the Length function generates 10 lines of ASM code to 2 lines if a simple comparison.
To easily find the places I use TotalComander with the search text with the option of regular expressions:
\([a-z.\d/_]+: string
; [a-z.\d/_]+: string
Length\([a-z.\d/_]+\) > 0
Length\([a-z.\d/_]+\) = 0
ODAC code style
Re: ODAC code style
Hello,
Thank you for the information, we try to use the CONST keyword and comparison without length in all key methods. In future, we will modify the whole code, where such expressions occur.
Thank you for the information, we try to use the CONST keyword and comparison without length in all key methods. In future, we will modify the whole code, where such expressions occur.
Re: ODAC code style
I want to recommend to use static code analyzers like:
CodeVerifier
Pascal Analyzer
CodeHealer
for make your code better and avoid mistakes.
Simple examle:
В файле "D:\odac90src\ODAC\Source\DBAccess.pas" сработали следующие проверки:
procedure TDAEncryption.EncryptDataSet(AutoCommitExplicitTransaction: Boolean = True)
...
for i := 0 to FOwner.FieldCount - 1 do
if FOwner.Fields.CanModify then
FOwner.Fields.Value := FOwner.Fields.Value; [строка 10049]: Левая и правая части присваивания совпадают
procedure TDADataSetUpdater.CheckUpdateSQL(const SQL: string;
...
NewSQL := NewSQL; [строка 11504]: Левая и правая части присваивания совпадают
CodeVerifier
Pascal Analyzer
CodeHealer
for make your code better and avoid mistakes.
Simple examle:
В файле "D:\odac90src\ODAC\Source\DBAccess.pas" сработали следующие проверки:
procedure TDAEncryption.EncryptDataSet(AutoCommitExplicitTransaction: Boolean = True)
...
for i := 0 to FOwner.FieldCount - 1 do
if FOwner.Fields.CanModify then
FOwner.Fields.Value := FOwner.Fields.Value; [строка 10049]: Левая и правая части присваивания совпадают
procedure TDADataSetUpdater.CheckUpdateSQL(const SQL: string;
...
NewSQL := NewSQL; [строка 11504]: Левая и правая части присваивания совпадают
Re: ODAC code style
Hello,
The string
is used for field data encryption, and since encryption is implemented in a setter, this is correct code.
The string
is added to fix a specific case when optimization is enabled in Delphi 5 and 6 leading to AV. We will add a correspondent define for this string
The string
Code: Select all
FOwner.Fields[i].Value := FOwner.Fields[i].Value;The string
Code: Select all
NewSQL := NewSQL;