mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 14:46:55 +01:00
Promote knowledge for Microsoft review skills (#153)
Move canonical knowledge for Microsoft-owned review domains into the Microsoft layer and document the skill/knowledge co-location policy. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com> Copilot-Session: 2a6ea875-d38e-4f30-aadb-0d606f9be231
This commit is contained in:
parent
bca8f478d8
commit
4f0a13a801
88 changed files with 11 additions and 7 deletions
|
|
@ -0,0 +1,41 @@
|
|||
codeunit 50540 "Perf Sample NoShortCircuit Good"
|
||||
{
|
||||
procedure ExceedsThreshold(var Thresholds: array[10] of Decimal; Index: Integer; Amount: Decimal): Boolean
|
||||
begin
|
||||
// 'and' is safe here: both operands are cheap and neither depends on the other.
|
||||
if (Index >= 1) and (Index <= ArrayLen(Thresholds)) then
|
||||
// The subscript lives in its own if, so it is never evaluated out of range.
|
||||
if Amount > Thresholds[Index] then
|
||||
exit(true);
|
||||
exit(false);
|
||||
end;
|
||||
|
||||
procedure IsBlockedCustomer(CustomerNo: Code[20]): Boolean
|
||||
var
|
||||
Customer: Record Customer;
|
||||
begin
|
||||
// The cheap test runs first, and the field is read only after Get succeeded.
|
||||
if CustomerNo = '' then
|
||||
exit(false);
|
||||
if not Customer.Get(CustomerNo) then
|
||||
exit(false);
|
||||
exit(Customer.Blocked <> Customer.Blocked::" ");
|
||||
end;
|
||||
|
||||
procedure IsEligibleForFreeShipping(SalesHeader: Record "Sales Header"): Boolean
|
||||
begin
|
||||
// 'or' is unsafe here: nesting would also be wrong, since it would drop the
|
||||
// case where the amount alone already qualifies. Exit as soon as the cheap
|
||||
// condition already decides the result; the costly lookup runs only on the
|
||||
// path where it can still change the outcome.
|
||||
if SalesHeader."Amount Including VAT" >= 1000 then
|
||||
exit(true);
|
||||
exit(HasActiveLoyaltyBenefit(SalesHeader."Sell-to Customer No."));
|
||||
end;
|
||||
|
||||
local procedure HasActiveLoyaltyBenefit(CustomerNo: Code[20]): Boolean
|
||||
begin
|
||||
// Stands in for a costly check — a webservice call or a large table scan.
|
||||
exit(CustomerNo <> '');
|
||||
end;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue