Optimize CacheContextsManager::optimizeTokens() performance

  • Add early return for single/empty token arrays (main optimization)
  • Use hash table (array_flip) for O(1) ancestor lookups instead of in_array()
  • Check ancestors before calling getService() to avoid unnecessary calls
  • Do NOT cache getCacheableMetadata() results as they can change mid-request

Closes #3457818

Merge request reports

Loading