Skip to content

Perf: Improve performance of basic ruby ops in DeclarativePolicy

username-removed-28993 requested to merge perf/policy-class-cache into master

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?

What are the relevant issue numbers?

Edited by username-removed-28993

Merge request reports

Loading