Skip to content

Commit 9c138b7

Browse files
author
kevyuu
committed
Fix indentation
1 parent 6e23e6e commit 9c138b7

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

include/nbl/asset/IPreHashed.h

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -39,61 +39,61 @@ class IPreHashed : public IAsset
3939
discardContent_impl();
4040
}
4141

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
6161
auto* isPrehashed = dynamic_cast<IPreHashed*>(entry);
6262
if (isPrehashed)
6363
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+
}
9797

9898
protected:
9999
inline IPreHashed() = default;

0 commit comments

Comments
 (0)