@@ -39,61 +39,61 @@ class IPreHashed : public IAsset
39
39
discardContent_impl ();
40
40
}
41
41
42
- static inline void discardDependantsContents (const std::span<IAsset*> roots)
43
- {
44
- core::stack <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 (node);
51
- return true ;
52
- };
53
- for (const auto & root : roots)
54
- push (root);
55
- while (!stack.empty ())
56
- {
57
- auto * entry = stack.top ();
58
- stack.pop ();
59
- entry->visitDependents (push);
60
- // post order traversal does discard
42
+ static inline void discardDependantsContents (const std::span<IAsset*> 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
61
auto * isPrehashed = dynamic_cast <IPreHashed*>(entry);
62
62
if (isPrehashed)
63
63
isPrehashed->discardContent ();
64
- }
65
- }
66
- static inline bool anyDependantDiscardedContents (const IAsset* root)
67
- {
68
- core::stack <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 = {} ;
80
- result = true ;
81
- return false ;
82
- }
83
- stack.push (node);
84
- }
85
- return true ;
86
- };
87
- if (!push (root))
88
- return true ;
89
- while (!stack.empty ())
90
- {
91
- auto * entry = stack.top ();
92
- stack.pop ();
93
- entry->visitDependents (push);
94
- }
95
- return result;
96
- }
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;
96
+ }
97
97
98
98
protected:
99
99
inline IPreHashed () = default;
0 commit comments