am 760a36f2: Merge "Factor out and speed up permission-checking code"

* commit '760a36f20702351f64863e14b2ae15ad1199fdcf':
  Factor out and speed up permission-checking code