Prefer String.IsEmpty over self-baken IsEmpty(String)

This commit is contained in:
Ansgar Becker
2020-07-04 08:12:17 +02:00
parent 1484f4d464
commit 8b548862de
5 changed files with 16 additions and 16 deletions

View File

@ -2811,7 +2811,7 @@ begin
Place := (Sender as TControl).Name
else
Place := 'unhandled-'+Sender.ClassName;
if IsNotEmpty(Anchor) then
if not Anchor.IsEmpty then
Anchor := '#'+Anchor;
ShellExec(APPDOMAIN+'help.php?place='+EncodeURLParam(Place)+Anchor);
end;
@ -3878,7 +3878,7 @@ var
KeyPath: String;
begin
PrepareRegistry;
if IsEmpty(FSessionPath) then
if FSessionPath.IsEmpty then
raise Exception.CreateFmt(_('No path set, won''t delete root key %s'), [FRegistry.CurrentPath])
else begin
KeyPath := REGKEY_SESSIONS + '\' + FSessionPath;
@ -3893,7 +3893,7 @@ var
KeyPath: String;
begin
PrepareRegistry;
if IsEmpty(FSessionPath) then
if FSessionPath.IsEmpty then
raise Exception.CreateFmt(_('No path set, won''t move root key %s'), [FRegistry.CurrentPath])
else begin
KeyPath := REGKEY_SESSIONS + '\' + FSessionPath;
@ -3966,9 +3966,9 @@ begin
ValueName := FSettings[Index].Name;
if FormatName <> '' then
ValueName := Format(ValueName, [FormatName]);
if FSettings[Index].Session and IsEmpty(FSessionPath) then
if FSettings[Index].Session and FSessionPath.IsEmpty then
raise Exception.Create(_('Attempt to read session setting without session path'));
if (not FSettings[Index].Session) and IsNotEmpty(FSessionPath) then
if (not FSettings[Index].Session) and (not FSessionPath.IsEmpty) then
SessionPath := ''
else
PrepareRegistry;
@ -4041,9 +4041,9 @@ begin
ValueName := FSettings[Index].Name;
if FormatName <> '' then
ValueName := Format(ValueName, [FormatName]);
if FSettings[Index].Session and IsEmpty(FSessionPath) then
if FSettings[Index].Session and FSessionPath.IsEmpty then
raise Exception.Create(_('Attempt to write session setting without session path'));
if (not FSettings[Index].Session) and IsNotEmpty(FSessionPath) then
if (not FSettings[Index].Session) and (not FSessionPath.IsEmpty) then
SessionPath := ''
else
PrepareRegistry;

View File

@ -137,7 +137,7 @@ begin
if IsNotEmpty(editFilter.Text) then begin
FLastFilter := editFilter.Text;
editFilter.Text := '';
end else if IsNotEmpty(FLastFilter) then begin
end else if not FLastFilter.IsEmpty then begin
editFilter.Text := FLastFilter;
FLastFilter := '';
end;

View File

@ -142,7 +142,7 @@ begin
popupRecentFilters.Items.Clear;
for i:=1 to 20 do begin
Filter := AppSettings.ReadString(asCopyTableRecentFilter, IntToStr(i));
if IsEmpty(Filter) then
if Filter.IsEmpty then
Continue;
Item := TMenuItem.Create(popupRecentFilters);
Item.Caption := IntToStr(i) + ' ' + StrEllipsis(Filter, 100);
@ -183,7 +183,7 @@ begin
NewValues.Add(MemoFilter.Text);
for i:=1 to 20 do begin
Filter := AppSettings.ReadString(asCopyTableRecentFilter, IntToStr(i));
if IsEmpty(Filter) then
if Filter.IsEmpty then
Continue;
if NewValues.IndexOf(Filter) = -1 then
NewValues.Add(Filter);

View File

@ -1551,7 +1551,7 @@ begin
if Item.Checked then
NewValue := NewValue + StripHotkey(Item.Caption) + ',';
end;
if not IsEmpty(NewValue) then
if not NewValue.IsEmpty then
Delete(NewValue, Length(NewValue), 1);
FTextEdit.Text := NewValue;
FModified := True;

View File

@ -3165,7 +3165,7 @@ begin
Tab := GetQueryTabByNumber(Thread.TabNumber);
// Error handling
if IsNotEmpty(Thread.ErrorMessage) then begin
if not Thread.ErrorMessage.IsEmpty then begin
SetProgressState(pbsError);
GoToErrorPos(Thread.ErrorMessage);
ErrorDialog(Thread.ErrorMessage);
@ -3242,7 +3242,7 @@ begin
// Assume that a bunch of up to 5 queries is not a batch.
AppSettings.ResetPath;
if AppSettings.ReadBool(asQueryHistoryEnabled)
and IsEmpty(Thread.ErrorMessage)
and Thread.ErrorMessage.IsEmpty
and (Thread.Batch.Count <= 5)
and (Thread.Batch.Size <= SIZE_MB)
then begin
@ -4832,7 +4832,7 @@ begin
// Add all other filenames
for i:=0 to 20 do begin
savedfilename := AppSettings.ReadString(asSQLfile, IntToStr(i));
if IsEmpty(savedfilename) then
if savedfilename.IsEmpty then
Break;
AppSettings.DeleteValue(asSQLfile, IntToStr(i));
if CheckIfFileExists and (not FileExists( savedfilename )) then
@ -4923,7 +4923,7 @@ begin
// Add old filters
for i:=1 to 20 do begin
val := AppSettings.ReadString(asRecentFilter, IntToStr(i));
if IsEmpty(val) then
if val.IsEmpty then
Continue;
if Filters.IndexOf(val) = -1 then
Filters.Add(val);
@ -10897,7 +10897,7 @@ begin
// Previously introduced bugs stored some other settings here, see issue #2127
item := TMenuItem.Create(popupFilter);
capt := AppSettings.ReadString(asRecentFilter, IntToStr(i));
if IsEmpty(capt) then
if capt.IsEmpty then
Break;
capt := rx.Replace(capt, ' ', True);
item.Hint := capt;