Refactor how permissions are matched by ProjectControl, RefControl
AccessSections are now matched onto references using pre-compiled
SectionMatcher objects. These matchers are built in the ProjectState
on demand, and cached until the ProjectState itself is discarded
from memory. This saves the Pattern.compile() costs, as well as some
basic conditionals to determine which type of reference pattern the
section uses, providing a small speed up to access rule evaluation.
ProjectControl and RefControl now stores all permissions that belong
to the project or reference, rather than only the ones relevant for
their CurrentUser. This allows the control objects to provide cached
data for other users, such as when ChangeControl needs to build a
different copy of itself for each reviewer listed on the change.
ProjectControl caches RefControls it builds, making it easier for
callers like ReceiveCommits or VisibleRefFilter to deal with a
lot of lookups for the same common reference name within a single
project access request. This comes at a cost of memory, but should
be an improvement in response time.
Project ownership checks are now handled by ProjectState, relying
on the cached localOwners data instead of looking at the OWNER
permission on "refs/*". The cached localOwners is already built up
from the "refs/*" data during ProjectState's constructor, so doing
it dynamically via RefControl inside of ProjectControl was really
quite wasteful.
Change-Id: Iaf12bab55d41217363cc05ba024f452d03bc21df
7 files changed