20 #ifndef PAGESPEED_KERNEL_BASE_SYMBOL_TABLE_H_
21 #define PAGESPEED_KERNEL_BASE_SYMBOL_TABLE_H_
33 namespace net_instaweb {
53 template<
class CharTransform>
class SymbolTable {
56 ~SymbolTable() {
Clear(); }
63 Atom
Intern(
const StringPiece& src);
72 bool operator()(
const StringPiece& key_a,
const StringPiece& key_b)
const {
73 if (key_a.length() == key_b.length()) {
74 const char* a = key_a.data();
75 const char* b = key_b.data();
76 const char* a_end = a + key_a.length();
78 if (CharTransform::Normalize(*a) != CharTransform::Normalize(*b)) {
92 size_t operator()(
const StringPiece& key)
const {
93 return HashString<CharTransform, size_t>(key.data(), key.length());
97 typedef dense_hash_map<StringPiece, StringPiece*,
98 Hash, Comparator> SymbolMap;
99 SymbolMap string_map_;
104 std::list<StringPiece> pieces_;
107 inline void NewStorage();
123 std::vector<char*> storage_;
125 size_t string_bytes_allocated_;
130 typedef SymbolTable<CaseFold> SymbolTableInsensitive;
131 typedef SymbolTable<CasePreserve> SymbolTableSensitive;
size_t string_bytes_allocated() const
Definition: symbol_table.h:67
Atom Intern(const StringPiece &src)
Remember a string in the table, returning it as an Atom.