The example here is:
if ! rpm -qa | grep -qw chrony; then
which can be written simply as:
if ! rpm -q chrony --quiet; then
or
if ! rpm -q --quiet chrony; then
Which in turn will use index in the RPM's sqlite DB (or previously BDB).
Reporting as directed on Twitter :-)