Esempio n. 1
0
void create_string_data_map() {
  StringDataMap::Config config;
  config.growthFactor = 1;
  MemoryStats::GetInstance()->ResetStaticStringSize();

  s_stringDataMap =
    new StringDataMap(RuntimeOption::EvalInitialStaticStringTableSize,
                      config);
  insertStaticString(StringData::MakeEmpty());
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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());
}
Esempio n. 4
0
inline StringData* insertStaticStringSlice(StringSlice slice) {
  return insertStaticString(StringData::MakeStatic(slice));
}