aboutsummaryrefslogtreecommitdiff
path: root/zenutil/cache/cachepolicy.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-02-07 15:52:22 +0100
committerPer Larsson <[email protected]>2022-02-07 15:52:22 +0100
commit51b890bcc61832fd5806a609ed8032bd27b4a707 (patch)
tree52914735b87e5250b5bb36ec8fbce8638fae3aac /zenutil/cache/cachepolicy.cpp
parentFormat fix. (diff)
parentMerging minor fixes to main (diff)
downloadzen-51b890bcc61832fd5806a609ed8032bd27b4a707.tar.xz
zen-51b890bcc61832fd5806a609ed8032bd27b4a707.zip
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenutil/cache/cachepolicy.cpp')
-rw-r--r--zenutil/cache/cachepolicy.cpp32
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