MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / destroy

Function destroy

Source/Common/Singleton.cpp:63–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 }
62
63 void destroy(String itemName = Slice::Empty) {
64 std::unordered_set<std::string> entries;
65 if (itemName.empty()) {
66 for (const auto& life : lives) {
67 entries.insert(life.first);
68 }
69 for (const auto& itemRef : itemRefs) {
70 entries.insert(itemRef.first);
71 }
72 for (auto& ref : refs) {
73 ref.visited = false;
74 auto entry = entries.find(ref.target);
75 if (entry != entries.end()) {
76 entries.erase(entry);
77 }
78 }
79 } else {
80 for (auto& ref : refs) {
81 ref.visited = false;
82 }
83 entries.insert(itemName.toString());
84 }
85 for (const auto& entry : entries) {
86 std::vector<std::string> items;
87 std::queue<std::string> refList;
88 refList.push(entry);
89 while (!refList.empty()) {
90 std::string name = refList.front();
91 refList.pop();
92 items.push_back(name);
93 auto it = itemRefs.find(name);
94 if (it != itemRefs.end()) {
95 for (Reference* ref : *it->second) {
96 if (!ref->visited) {
97 ref->visited = true;
98 refList.push(ref->target);
99 }
100 }
101 }
102 }
103#if DORA_DEBUG
104 std::unordered_set<std::string> names;
105 std::vector<std::string> nameList;
106 for (auto it = items.rbegin(); it != items.rend(); ++it) {
107 if (names.find(*it) == names.end() && lives.find(*it) != lives.end()) {
108 names.insert(*it);
109 nameList.push_back(*it);
110 }
111 }
112 if (!nameList.empty()) {
113 LogInfo(fmt::format("destroy: {}.", std::accumulate(nameList.begin() + 1, nameList.end(), nameList.front(), [](const std::string& a, const std::string& b) {
114 return a + ", " + b;
115 })));
116 }
117#endif // DORA_DEBUG
118 for (auto it = items.rbegin(); it != items.rend(); ++it) {
119 lives.erase(*it);
120 itemRefs.erase(*it);

Callers 15

~LifeCyclerFunction · 0.70
~RenderTargetMethod · 0.50
saveAsyncMethod · 0.50
mainLogicMethod · 0.50
mainFunction · 0.50
WinMainFunction · 0.50
~Texture2DMethod · 0.50
~ShaderMethod · 0.50
~UniformMethod · 0.50
~PassMethod · 0.50
~SpriteEffectMethod · 0.50
updateMethod · 0.50

Calls 15

LogInfoFunction · 0.85
insertMethod · 0.65
findMethod · 0.65
toStringMethod · 0.65
pushMethod · 0.65
popMethod · 0.65
formatFunction · 0.50
emptyMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
frontMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected