diff options
Diffstat (limited to 'zenutil/cache/cachepolicy.cpp')
| -rw-r--r-- | zenutil/cache/cachepolicy.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/zenutil/cache/cachepolicy.cpp b/zenutil/cache/cachepolicy.cpp index 7e6477cd4..8c10ea674 100644 --- a/zenutil/cache/cachepolicy.cpp +++ b/zenutil/cache/cachepolicy.cpp @@ -20,7 +20,7 @@ using namespace std::literals; namespace DerivedData::Private { - constexpr char CachePolicyDelimiter = ','; + constinit char CachePolicyDelimiter = ','; struct CachePolicyToTextData { @@ -28,7 +28,7 @@ namespace DerivedData::Private { std::string_view Text; }; - const CachePolicyToTextData CachePolicyToText[]{ + constinit CachePolicyToTextData CachePolicyToText[]{ // Flags with multiple bits are ordered by bit count to minimize token count in the text format. {CachePolicy::Default, "Default"sv}, {CachePolicy::Remote, "Remote"sv}, @@ -48,7 +48,7 @@ namespace DerivedData::Private { {CachePolicy::None, "None"sv}, }; - constexpr CachePolicy CachePolicyKnownFlags = + constinit CachePolicy CachePolicyKnownFlags = CachePolicy::Default | CachePolicy::SkipMeta | CachePolicy::SkipData | CachePolicy::PartialRecord | CachePolicy::KeepAlive; StringBuilderBase& CachePolicyToString(StringBuilderBase& Builder, CachePolicy Policy) @@ -120,11 +120,27 @@ ConvertToUpstream(CachePolicy Policy) // Set Local flags equal to downstream's Remote flags. // Delete Skip flags if StoreLocal is true, otherwise use the downstream value. // Use the downstream value for all other flags. - return (EnumHasAllFlags(Policy, CachePolicy::QueryRemote) ? CachePolicy::QueryLocal : CachePolicy::None) | - (EnumHasAllFlags(Policy, CachePolicy::StoreRemote) ? CachePolicy::StoreLocal : CachePolicy::None) | - (!EnumHasAllFlags(Policy, CachePolicy::StoreLocal) ? (Policy & (CachePolicy::SkipData | CachePolicy::SkipMeta)) - : CachePolicy::None) | - (Policy & ~(CachePolicy::Local | CachePolicy::SkipData | CachePolicy::SkipMeta)); + + CachePolicy UpstreamPolicy = CachePolicy::None; + + if (EnumHasAllFlags(Policy, CachePolicy::QueryRemote)) + { + UpstreamPolicy |= CachePolicy::QueryLocal; + } + + if (EnumHasAllFlags(Policy, CachePolicy::StoreRemote)) + { + UpstreamPolicy |= CachePolicy::StoreLocal; + } + + if (!EnumHasAllFlags(Policy, CachePolicy::StoreLocal)) + { + UpstreamPolicy |= (Policy & (CachePolicy::SkipData | CachePolicy::SkipMeta)); + } + + UpstreamPolicy |= Policy & ~(CachePolicy::Local | CachePolicy::SkipData | CachePolicy::SkipMeta); + + return UpstreamPolicy; } class Private::CacheRecordPolicyShared final : public Private::ICacheRecordPolicyShared |