Since the imrpovements to accesslib caching in
MDL-49398, we now have cached all the role_capabilities for each role.
Therefore, there are many accesslib functions that could now quite easily save DB queries. E.g. get_roles_with_cap_in_context, role_context_capabilities, the queries in role_change_permission that decide whether anything needs to be changed, ...
Just creating this as a placeholder that this would be worth doing.