Add 'if IsEmpty then FindSet' patern vs only 'FindSet' - #257
Add 'if IsEmpty then FindSet' patern vs only 'FindSet'#257Stefan Sosic (StefanSosic) wants to merge 1 commit into
Conversation
Stefan Sosic (StefanSosic)
commented
Jun 4, 2025





|
With the "new" internal procedure FindSetWithoutIsEmpty()
var
Customer: Record Customer;
i: Integer;
begin
for i := 1 to 10 do begin
Customer.SetRange("Country/Region Code", 'RS');
if not Customer.FindSet() then
continue;
// Now we definitely have data we can process
// ...
end;
end;Another example: internal procedure ProcessDECustomers()
var
Customer: Record Customer;
begin
Customer.SetRange("Country/Region Code", 'DE');
if not Customer.FindSet() then
exit;
repeat
// Process data here...
until Customer.Next() = 0;
end;What do you think? |
|
Marcel (@mexby) using early exit like this is horrible for me, but maybe you'd better post this question in the right thread: #253 Related to this PR: maybe it should be more clear that |
|
This one is well crafted, but maybe we should do a chat sometime and reconcile with the Discussion thread on it? |
|
If an optimization is needed, shouldn't Microsoft simply handle it behind the scenes? |