MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / cleanup

Method cleanup

modules/gui/gui/src/backend/text_server/string_name.cpp:83–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void StringName::cleanup()
84{
85 MutexLock lock(mutex);
86
87#ifdef DEBUG_ENABLED
88 if (unlikely(debug_stringname))
89 {
90 Vector<_Data*> data;
91 for (int i = 0; i < STRING_TABLE_LEN; i++)
92 {
93 _Data* d = _table[i];
94 while (d)
95 {
96 data.push_back(d);
97 d = d->next;
98 }
99 }
100
101 print_line("\nStringName reference ranking (from most to least referenced):\n");
102
103 data.sort_custom<DebugSortReferences>();
104 int unreferenced_stringnames = 0;
105 int rarely_referenced_stringnames = 0;
106 for (int i = 0; i < data.size(); i++)
107 {
108 print_line(itos(i + 1) + ": " + data[i]->get_name() + " - " + itos(data[i]->debug_references));
109 if (data[i]->debug_references == 0)
110 {
111 unreferenced_stringnames += 1;
112 }
113 else if (data[i]->debug_references < 5)
114 {
115 rarely_referenced_stringnames += 1;
116 }
117 }
118
119 print_line(vformat("\nOut of %d StringNames, %d StringNames were never referenced during this run (0 times) (%.2f%%).", data.size(), unreferenced_stringnames, unreferenced_stringnames / float(data.size()) * 100));
120 print_line(vformat("Out of %d StringNames, %d StringNames were rarely referenced during this run (1-4 times) (%.2f%%).", data.size(), rarely_referenced_stringnames, rarely_referenced_stringnames / float(data.size()) * 100));
121 }
122#endif
123 int lost_strings = 0;
124 for (int i = 0; i < STRING_TABLE_LEN; i++)
125 {
126 while (_table[i])
127 {
128 _Data* d = _table[i];
129 if (d->static_count.get() != d->refcount.get())
130 {
131 lost_strings++;
132
133 if (kVerbose())
134 {
135 if (d->cname)
136 {
137 print_line("Orphan StringName: " + String(d->cname));
138 }
139 else
140 {

Callers

nothing calls this directly

Calls 11

print_lineFunction · 0.85
itosFunction · 0.85
vformatFunction · 0.85
kVerboseFunction · 0.85
memdeleteFunction · 0.85
print_verboseFunction · 0.85
StringClass · 0.70
push_backMethod · 0.45
sizeMethod · 0.45
get_nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected