void create_string_data_map() { StringDataMap::Config config; config.growthFactor = 1; MemoryStats::GetInstance()->ResetStaticStringSize(); s_stringDataMap = new StringDataMap(RuntimeOption::EvalInitialStaticStringTableSize, config); insertStaticString(StringData::MakeEmpty()); }
StringData* makeStaticString(StringSlice slice) { if (UNLIKELY(!s_stringDataMap)) { create_string_data_map(); } auto const it = s_stringDataMap->find(make_intern_key(&slice)); if (it != s_stringDataMap->end()) { return const_cast<StringData*>(to_sdata(it->first)); } return insertStaticString(slice); }
StringData* makeStaticString(const StringData* str) { if (UNLIKELY(!s_stringDataMap)) { create_string_data_map(); } if (str->isStatic()) { assert(checkStaticStr(str)); return const_cast<StringData*>(str); } auto const it = s_stringDataMap->find(make_intern_key(str)); if (it != s_stringDataMap->end()) { return const_cast<StringData*>(to_sdata(it->first)); } return insertStaticString(str->slice()); }
inline StringData* insertStaticStringSlice(StringSlice slice) { return insertStaticString(StringData::MakeStatic(slice)); }