We use const char * throughout this code instead of std::string to avoid having to allocate memory for all the small string literals. This significantly speeds up processing and allows us to handle very large maps (e.g. 16x16 embarks) without running out of memory. This cache provides a mechanism for storing dynamically created strings so their memory stays allocated until we write out the bluepri
| 238 | // allocated until we write out the blueprints at the end. |
| 239 | // If NULL is passed as the str, the cache is cleared. |
| 240 | static const char * cache(const char *str) { |
| 241 | if (!str) |
| 242 | return NULL; |
| 243 | return string_cache.emplace(str).first->c_str(); |
| 244 | } |
| 245 | |
| 246 | // Convenience wrapper for std::string. |
| 247 | static const char * cache(const string &str) { |
no test coverage detected