| 81 | } |
| 82 | |
| 83 | void 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 | { |
nothing calls this directly
no test coverage detected