Repository navigation
knowledge(performance): Get behind a key-is-set check in and-condition wastes a DB call - #275
Draft
Kilian Seizinger (pri-kise) wants to merge 1 commit into
Draft
Kilian Seizinger (pri-kise) wants to merge 1 commit into
Kilian Seizinger (pri-kise) wants to merge 1 commit into
Conversation
…n wastes a DB call Extend the no-short-circuit rule with the case where Rec.Get is the dependent operand behind a Key <> 0 / '' check and only a field value or default is returned: nothing breaks, but every call with an unset key sends a query that cannot find a record. Add GetEntryDescription to the bad/good samples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was
Erweitert
boolean-operators-do-not-short-circuitum den Fall, dassRecord.Get(...)der abhängige Operand hinter einer Key-Prüfung ist:if (EntryNo <> 0) and Rec.Get(EntryNo) then exit(Rec.Field); exit('');Das ist nicht unsicher, schickt aber bei
EntryNo = 0jedes Mal eine Datenbankabfrage, die nichts finden kann. Es geht um Performance, nicht um Korrektheit.Änderungen
if EntryNo = 0 then exit('')),Geterst danach.Rec.Get(Key)hinterKey <> 0bzw.Key <> '', wenn nur ein Feldwert oder Default zurückgegeben wird.GetEntryDescriptionin.bad.alund.good.al.Keine neue Datei, weil die Regel das Muster bereits abdeckt und sonst ein Duplikat entstünde.
Prüfung
Test-ReviewFixtures.ps1läuft durch.