| 246 | |
| 247 | namespace internal { |
| 248 | uint16* WorkingMemory::GetHashTable(size_t input_size, int* table_size) { |
| 249 | // Use smaller hash table when input.size() is smaller, since we |
| 250 | // fill the table, incurring O(hash table size) overhead for |
| 251 | // compression, and if the input is short, we won't need that |
| 252 | // many hash table entries anyway. |
| 253 | assert(kMaxHashTableSize >= 256); |
| 254 | size_t htsize = 256; |
| 255 | while (htsize < kMaxHashTableSize && htsize < input_size) { |
| 256 | htsize <<= 1; |
| 257 | } |
| 258 | |
| 259 | uint16* table; |
| 260 | if (htsize <= ARRAYSIZE(small_table_)) { |
| 261 | table = small_table_; |
| 262 | } else { |
| 263 | if (large_table_ == NULL) { |
| 264 | large_table_ = new uint16[kMaxHashTableSize]; |
| 265 | } |
| 266 | table = large_table_; |
| 267 | } |
| 268 | |
| 269 | *table_size = htsize; |
| 270 | memset(table, 0, htsize * sizeof(*table)); |
| 271 | return table; |
| 272 | } |
| 273 | } // end namespace internal |
| 274 | |
| 275 | // For 0 <= offset <= 4, GetUint32AtOffset(GetEightBytesAt(p), offset) will |
no outgoing calls