Perf: Improve performance of basic ruby ops in DeclarativePolicy
What does this MR do?
- Adds a cache to
DeclarativePolicy.cache_for
, since Module#name can be very expensive for anonymous classes/modules: https://bugs.ruby-lang.org/issues/11119 - Caches
ManifestCondition#cache_key
to save string ops, since it can be called a lot of times - Avoids
#respond_to?
in#id_for
, since it can be very slow for ActiveRecord objects.
Are there points in the code the reviewer needs to double check?
Why was this MR needed?
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Edited by username-removed-28993