# perf\(ledger\): short-circuit command kind checks \(\#187\) · lucenx/codexbar-plasma

[View on GitCafe](https://git.cafe/lucenx/codexbar-plasma/commit/1bb7d7929eebb4577c4083e731765bfa7d765041)

Repository: [lucenx/codexbar-plasma](https://git.cafe/lucenx/codexbar-plasma)

Visibility: public

Requested revision: 1bb7d7929eebb4577c4083e731765bfa7d765041

Requested commit: 1bb7d7929eebb4577c4083e731765bfa7d765041

Commit: 1bb7d7929eebb4577c4083e731765bfa7d765041

Tree: da1a1021beca1c2b69e63002e4ad31d85810c9cc

Author: Simone

Committer: GitHub

## Message

```
perf(ledger): short-circuit command kind checks (#187)

* perf: eliminate redundant CommandLedger lookups in command loops

Avoid calling CommandLedger.find inside loops over command sources in
retireStaleAccountCommands and AccountRequests.isLoading by providing
CommandLedger.entriesOfKind which returns source names and descriptors in a
single pass. Also optimize CommandLedger.hasKind to short-circuit on match.

Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>

* perf(ledger): optimize CommandLedger entry lookups in account command loops

Avoid calling CommandLedger.find inside loops over command sources in
retireStaleAccountCommands and AccountRequests.isLoading by providing
CommandLedger.entriesOfKind which returns source names and descriptors in a
single pass. Also optimize CommandLedger.hasKind to short-circuit on match.

Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>

* perf(ledger): optimize CommandLedger entry lookups in account command loops

Avoid calling CommandLedger.find inside loops over command sources in
retireStaleAccountCommands and AccountRequests.isLoading by providing
CommandLedger.entriesOfKind which returns source names and descriptors in a
single pass. Also optimize CommandLedger.hasKind to short-circuit on match.

Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>

* perf(ledger): keep only short-circuit kind checks

Drop the entriesOfKind API and account caller changes after Qt measurements showed no consistent benefit. Preserve hasKind filtering and exact matching with adversarial tests. Documentation, configuration, translations and TODO are unchanged because this is an internal query optimization. Strict make check passed in the pinned KDE neon environment.

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>
```

## Parents

- [a2db657f5bef5775b1d24d11c01fdd6a97368b95](https://git.cafe/lucenx/codexbar-plasma/commit/a2db657f5bef5775b1d24d11c01fdd6a97368b95?format=markdown)

[Source at this commit](https://git.cafe/lucenx/codexbar-plasma/tree/1bb7d7929eebb4577c4083e731765bfa7d765041?format=markdown)
