| 232 | |
| 233 | |
| 234 | DetailIndex NameToIndex(const char* str, NameToIndexMap& nameToIndex) |
| 235 | { |
| 236 | HashedString hashedName(str); |
| 237 | auto it = nameToIndex.find(hashedName); |
| 238 | if (it != nameToIndex.end()) |
| 239 | return it->second; |
| 240 | |
| 241 | char* strCopy; |
| 242 | { |
| 243 | // arena allocator is not thread safe, take a mutex |
| 244 | std::scoped_lock lock(arenaMutex); |
| 245 | strCopy = (char*)ArenaAllocate(hashedName.len+1); |
| 246 | } |
| 247 | memcpy(strCopy, str, hashedName.len+1); |
| 248 | hashedName.str = strCopy; |
| 249 | |
| 250 | DetailIndex index((int)nameToIndex.size()); |
| 251 | nameToIndex.insert(std::make_pair(hashedName, index)); |
| 252 | return index; |
| 253 | } |
| 254 | |
| 255 | bool ParseRoot(simdjson::dom::element& it, const std::string& curFileName) |
| 256 | { |
nothing calls this directly
no test coverage detected