| 111 | } |
| 112 | |
| 113 | HandleBase* Insert(HandleBase* h) { |
| 114 | HandleBase** ptr = FindPointer(h->key(), h->hash()); |
| 115 | HandleBase* old = *ptr; |
| 116 | h->next_handle_ = (old == nullptr ? nullptr : old->next_handle_); |
| 117 | *ptr = h; |
| 118 | if (old == nullptr) { |
| 119 | ++elems_; |
| 120 | if (elems_ > length_) { |
| 121 | // Since each cache entry is fairly large, we aim for a small |
| 122 | // average linked list length (<= 1). |
| 123 | Resize(); |
| 124 | } |
| 125 | } else { |
| 126 | old->next_handle_ = nullptr; |
| 127 | } |
| 128 | return old; |
| 129 | } |
| 130 | |
| 131 | HandleBase* Remove(const Slice& key, uint32_t hash) { |
| 132 | HandleBase** ptr = FindPointer(key, hash); |