@@ -39,61 +39,61 @@ class IPreHashed : public IAsset
3939 discardContent_impl ();
4040 }
4141
42- static inline void discardDependantsContents (const std::span<IAsset* const > roots)
43- {
44- core::vector<IAsset*> stack;
45- core::unordered_set<IAsset*> alreadyVisited; // whether we have push the node to the stack
46- auto push = [&stack,&alreadyVisited](IAsset* node) -> bool
47- {
48- const auto [dummy,inserted] = alreadyVisited.insert (node);
49- if (inserted)
50- stack.push_back (node);
51- return true ;
52- };
53- for (const auto & root : roots)
54- push (root);
55- while (!stack.empty ())
56- {
57- auto * entry = stack.back ();
58- stack.pop_back ();
59- entry->visitDependents (push);
60- // pre order traversal does discard
61- auto * isPrehashed = dynamic_cast <IPreHashed*>(entry);
62- if (isPrehashed)
63- isPrehashed->discardContent ();
64- }
65- }
66- static inline bool anyDependantDiscardedContents (const IAsset* root)
67- {
68- core::vector<const IAsset*> stack;
69- core::unordered_set<const IAsset*> alreadyVisited; // whether we have push the node to the stack
70- bool result = false ;
71- auto push = [&stack,&alreadyVisited,&result](const IAsset* node) -> bool
72- {
73- const auto [dummy,inserted] = alreadyVisited.insert (node);
74- if (inserted)
42+ static inline void discardDependantsContents (const std::span<IAsset* const > roots)
7543 {
76- auto * isPrehashed = dynamic_cast <const IPreHashed*>(node);
77- if (isPrehashed && isPrehashed->missingContent ())
78- {
79- stack.clear ();
80- result = true ;
81- return false ;
82- }
83- stack.push_back (node);
44+ core::vector<IAsset*> stack;
45+ core::unordered_set<IAsset*> alreadyVisited; // whether we have push the node to the stack
46+ auto push = [&stack,&alreadyVisited](IAsset* node) -> bool
47+ {
48+ const auto [dummy,inserted] = alreadyVisited.insert (node);
49+ if (inserted)
50+ stack.push_back (node);
51+ return true ;
52+ };
53+ for (const auto & root : roots)
54+ push (root);
55+ while (!stack.empty ())
56+ {
57+ auto * entry = stack.back ();
58+ stack.pop_back ();
59+ entry->visitDependents (push);
60+ // pre order traversal does discard
61+ auto * isPrehashed = dynamic_cast <IPreHashed*>(entry);
62+ if (isPrehashed)
63+ isPrehashed->discardContent ();
64+ }
65+ }
66+ static inline bool anyDependantDiscardedContents (const IAsset* root)
67+ {
68+ core::vector<const IAsset*> stack;
69+ core::unordered_set<const IAsset*> alreadyVisited; // whether we have push the node to the stack
70+ bool result = false ;
71+ auto push = [&stack,&alreadyVisited,&result](const IAsset* node) -> bool
72+ {
73+ const auto [dummy,inserted] = alreadyVisited.insert (node);
74+ if (inserted)
75+ {
76+ auto * isPrehashed = dynamic_cast <const IPreHashed*>(node);
77+ if (isPrehashed && isPrehashed->missingContent ())
78+ {
79+ stack.clear ();
80+ result = true ;
81+ return false ;
82+ }
83+ stack.push_back (node);
84+ }
85+ return true ;
86+ };
87+ if (!push (root))
88+ return true ;
89+ while (!stack.empty ())
90+ {
91+ auto * entry = stack.back ();
92+ stack.pop_back ();
93+ entry->visitDependents (push);
94+ }
95+ return result;
8496 }
85- return true ;
86- };
87- if (!push (root))
88- return true ;
89- while (!stack.empty ())
90- {
91- auto * entry = stack.back ();
92- stack.pop_back ();
93- entry->visitDependents (push);
94- }
95- return result;
96- }
9797
9898 protected:
9999 inline IPreHashed () = default;
0 commit comments