Coverage Report

Created: 2025-07-18 06:42

/src/aspell/common/hash-t.hpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2001,2011
2
// Kevin Atkinson
3
//
4
// Permission to use, copy, modify, distribute and sell this software
5
// and its documentation for any purpose is hereby granted without fee,
6
// provided that the above copyright notice appear in all copies and
7
// that both that copyright notice and this permission notice appear
8
// in supporting documentation.  Silicon Graphics makes no
9
// representations about the suitability of this software for any
10
// purpose.  It is provided "as is" without express or implied warranty.
11
12
// prime list taken from SGI STL with the following copyright
13
14
/*
15
 * Copyright (c) 1996-1998
16
 * Silicon Graphics Computer Systems, Inc.
17
 *
18
 * Permission to use, copy, modify, distribute and sell this software
19
 * and its documentation for any purpose is hereby granted without fee,
20
 * provided that the above copyright notice appear in all copies and
21
 * that both that copyright notice and this permission notice appear
22
 * in supporting documentation.  Silicon Graphics makes no
23
 * representations about the suitability of this software for any
24
 * purpose.  It is provided "as is" without express or implied warranty.
25
 *
26
 *
27
 * Copyright (c) 1994
28
 * Hewlett-Packard Company
29
 *
30
 * Permission to use, copy, modify, distribute and sell this software
31
 * and its documentation for any purpose is hereby granted without fee,
32
 * provided that the above copyright notice appear in all copies and
33
 * that both that copyright notice and this permission notice appear
34
 * in supporting documentation.  Hewlett-Packard Company makes no
35
 * representations about the suitability of this software for any
36
 * purpose.  It is provided "as is" without express or implied warranty.
37
 *
38
 */
39
40
#ifndef autil__hash_t_hh
41
#define autil__hash_t_hh
42
43
#include <cstdlib>
44
#include <new>
45
46
#include "hash.hpp"
47
#include "block_slist-t.hpp"
48
49
namespace acommon {
50
  
51
  static const unsigned int primes[] =
52
  {
53
    53,         97,         193,       389,       769,
54
    1543,       3079,       6151,      12289,     24593,
55
    49157,      98317,      196613,    393241,    786433,
56
    1572869,    3145739,    6291469,   12582917,  25165843,
57
    50331653,   100663319,  201326611, 402653189, 805306457, 
58
    static_cast<unsigned int>(-1)
59
  };
60
61
  template <class P>
62
  typename HashTable<P>::PrimeIndex HashTable<P>::next_largest(Size s) 
63
24.3k
  {
64
24.3k
    PrimeIndex i = prime_index_;
65
24.3k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
24.3k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::next_largest(unsigned int)
Line
Count
Source
63
340
  {
64
340
    PrimeIndex i = prime_index_;
65
340
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
340
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::next_largest(unsigned int)
Line
Count
Source
63
17.9k
  {
64
17.9k
    PrimeIndex i = prime_index_;
65
17.9k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
17.9k
  }
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::next_largest(unsigned int)
Line
Count
Source
63
3.05k
  {
64
3.05k
    PrimeIndex i = prime_index_;
65
3.05k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.05k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int)
Line
Count
Source
63
3.05k
  {
64
3.05k
    PrimeIndex i = prime_index_;
65
3.05k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.05k
  }
68
69
  template <class P>
70
100k
  void HashTable<P>::create_table(PrimeIndex i) {
71
100k
    prime_index_ = i;
72
100k
    table_size_ = primes[prime_index_];
73
100k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
100k
    table_end_ = table_ + table_size_;
75
100k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
100k
  }
acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int)
Line
Count
Source
70
64.4k
  void HashTable<P>::create_table(PrimeIndex i) {
71
64.4k
    prime_index_ = i;
72
64.4k
    table_size_ = primes[prime_index_];
73
64.4k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
64.4k
    table_end_ = table_ + table_size_;
75
64.4k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
64.4k
  }
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int)
Line
Count
Source
70
1.13k
  void HashTable<P>::create_table(PrimeIndex i) {
71
1.13k
    prime_index_ = i;
72
1.13k
    table_size_ = primes[prime_index_];
73
1.13k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
1.13k
    table_end_ = table_ + table_size_;
75
1.13k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
1.13k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::create_table(unsigned int)
Line
Count
Source
70
388
  void HashTable<P>::create_table(PrimeIndex i) {
71
388
    prime_index_ = i;
72
388
    table_size_ = primes[prime_index_];
73
388
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
388
    table_end_ = table_ + table_size_;
75
388
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
388
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int)
Line
Count
Source
70
28.3k
  void HashTable<P>::create_table(PrimeIndex i) {
71
28.3k
    prime_index_ = i;
72
28.3k
    table_size_ = primes[prime_index_];
73
28.3k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
28.3k
    table_end_ = table_ + table_size_;
75
28.3k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
28.3k
  }
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::create_table(unsigned int)
Line
Count
Source
70
3.05k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.05k
    prime_index_ = i;
72
3.05k
    table_size_ = primes[prime_index_];
73
3.05k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.05k
    table_end_ = table_ + table_size_;
75
3.05k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.05k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int)
Line
Count
Source
70
3.05k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.05k
    prime_index_ = i;
72
3.05k
    table_size_ = primes[prime_index_];
73
3.05k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.05k
    table_end_ = table_ + table_size_;
75
3.05k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.05k
  }
77
78
  template <class P>
79
  void HashTable<P>::init(PrimeIndex i)
80
89.3k
  {
81
89.3k
    size_ = 0;
82
89.3k
    create_table(i);
83
89.3k
    node_pool_.add_block(primes[i]);
84
89.3k
  }
acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int)
Line
Count
Source
80
63.9k
  {
81
63.9k
    size_ = 0;
82
63.9k
    create_table(i);
83
63.9k
    node_pool_.add_block(primes[i]);
84
63.9k
  }
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int)
Line
Count
Source
80
1.02k
  {
81
1.02k
    size_ = 0;
82
1.02k
    create_table(i);
83
1.02k
    node_pool_.add_block(primes[i]);
84
1.02k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
Line
Count
Source
80
340
  {
81
340
    size_ = 0;
82
340
    create_table(i);
83
340
    node_pool_.add_block(primes[i]);
84
340
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int)
Line
Count
Source
80
17.9k
  {
81
17.9k
    size_ = 0;
82
17.9k
    create_table(i);
83
17.9k
    node_pool_.add_block(primes[i]);
84
17.9k
  }
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
Line
Count
Source
80
3.05k
  {
81
3.05k
    size_ = 0;
82
3.05k
    create_table(i);
83
3.05k
    node_pool_.add_block(primes[i]);
84
3.05k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int)
Line
Count
Source
80
3.05k
  {
81
3.05k
    size_ = 0;
82
3.05k
    create_table(i);
83
3.05k
    node_pool_.add_block(primes[i]);
84
3.05k
  }
85
86
  template <class P>
87
  std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert)
88
1.60M
  {
89
1.60M
    bool have;
90
1.60M
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
1.60M
    if (have && !parms_.is_multi) 
92
590k
      return std::pair<iterator,bool>(put_me_here,false);
93
1.01M
    Node * new_node = node_pool_.new_node();
94
1.01M
    if (new_node == 0) {
95
11.1k
      resize_i(prime_index_+1);
96
11.1k
      return insert(to_insert);
97
11.1k
    }
98
1.00M
    new 
99
1.00M
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
1.00M
      Value(to_insert);
101
1.00M
    new_node->next = *put_me_here.n;
102
1.00M
    *put_me_here.n = new_node;
103
1.00M
    ++size_;
104
1.00M
    return std::pair<iterator,bool>(put_me_here,true);
105
1.01M
  }
acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&)
Line
Count
Source
88
53.6k
  {
89
53.6k
    bool have;
90
53.6k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
53.6k
    if (have && !parms_.is_multi) 
92
14.4k
      return std::pair<iterator,bool>(put_me_here,false);
93
39.1k
    Node * new_node = node_pool_.new_node();
94
39.1k
    if (new_node == 0) {
95
510
      resize_i(prime_index_+1);
96
510
      return insert(to_insert);
97
510
    }
98
38.6k
    new 
99
38.6k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
38.6k
      Value(to_insert);
101
38.6k
    new_node->next = *put_me_here.n;
102
38.6k
    *put_me_here.n = new_node;
103
38.6k
    ++size_;
104
38.6k
    return std::pair<iterator,bool>(put_me_here,true);
105
39.1k
  }
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&)
Line
Count
Source
88
23.5k
  {
89
23.5k
    bool have;
90
23.5k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
23.5k
    if (have && !parms_.is_multi) 
92
0
      return std::pair<iterator,bool>(put_me_here,false);
93
23.5k
    Node * new_node = node_pool_.new_node();
94
23.5k
    if (new_node == 0) {
95
102
      resize_i(prime_index_+1);
96
102
      return insert(to_insert);
97
102
    }
98
23.4k
    new 
99
23.4k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
23.4k
      Value(to_insert);
101
23.4k
    new_node->next = *put_me_here.n;
102
23.4k
    *put_me_here.n = new_node;
103
23.4k
    ++size_;
104
23.4k
    return std::pair<iterator,bool>(put_me_here,true);
105
23.5k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::insert(char const* const&)
Line
Count
Source
88
112k
  {
89
112k
    bool have;
90
112k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
112k
    if (have && !parms_.is_multi) 
92
102k
      return std::pair<iterator,bool>(put_me_here,false);
93
10.2k
    Node * new_node = node_pool_.new_node();
94
10.2k
    if (new_node == 0) {
95
48
      resize_i(prime_index_+1);
96
48
      return insert(to_insert);
97
48
    }
98
10.2k
    new 
99
10.2k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
10.2k
      Value(to_insert);
101
10.2k
    new_node->next = *put_me_here.n;
102
10.2k
    *put_me_here.n = new_node;
103
10.2k
    ++size_;
104
10.2k
    return std::pair<iterator,bool>(put_me_here,true);
105
10.2k
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&)
Line
Count
Source
88
1.41M
  {
89
1.41M
    bool have;
90
1.41M
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
1.41M
    if (have && !parms_.is_multi) 
92
473k
      return std::pair<iterator,bool>(put_me_here,false);
93
945k
    Node * new_node = node_pool_.new_node();
94
945k
    if (new_node == 0) {
95
10.4k
      resize_i(prime_index_+1);
96
10.4k
      return insert(to_insert);
97
10.4k
    }
98
934k
    new 
99
934k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
934k
      Value(to_insert);
101
934k
    new_node->next = *put_me_here.n;
102
934k
    *put_me_here.n = new_node;
103
934k
    ++size_;
104
934k
    return std::pair<iterator,bool>(put_me_here,true);
105
945k
  }
Unexecuted instantiation: writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::insert(char const* const&)
Unexecuted instantiation: acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::insert(std::__1::pair<char const* const, acommon::Vector<char const*> > const&)
106
  
107
  template <class P>
108
  void HashTable<P>::erase(iterator to_erase) 
109
  {
110
    (*to_erase.n)->data.~Value();
111
    Node * tmp = *to_erase.n;
112
    *to_erase.n = (*to_erase.n)->next;
113
    node_pool_.remove_node(tmp);
114
    --size_;
115
  }
116
117
  template <class P>
118
  typename HashTable<P>::Size HashTable<P>::erase(const Key & k)
119
403
  {
120
403
    Size num_erased = 0;
121
403
    bool irrelevant;
122
403
    Node * * first = find_i(k,irrelevant).n;
123
403
    Node * n = *first;
124
508
    while (n != 0 && parms_.equal(parms_.key(n->data), k)) {
125
105
      Node * tmp = n;
126
105
      n->data.~Value();
127
105
      n = n->next;
128
105
      node_pool_.remove_node(tmp);
129
105
      ++num_erased;
130
105
    }
131
403
    *first = n;
132
403
    size_ -= num_erased;
133
403
    return num_erased;
134
403
  }
135
  
136
  template <class P>
137
  typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have)
138
43.4M
  {
139
43.4M
    Size pos = parms_.hash(to_find) % table_size_;
140
43.4M
    Node * * n = table_ + pos;
141
43.4M
    have = false;
142
45.4M
    while (true) {
143
45.4M
      if (*n == 0) {
144
41.9M
  break;
145
41.9M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
1.51M
  have = true;
147
1.51M
  break;
148
1.51M
      }
149
1.95M
      n = &(*n)->next;
150
1.95M
    }
151
43.4M
    return iterator(table_ + pos, n);
152
43.4M
  }
acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&)
Line
Count
Source
138
303k
  {
139
303k
    Size pos = parms_.hash(to_find) % table_size_;
140
303k
    Node * * n = table_ + pos;
141
303k
    have = false;
142
446k
    while (true) {
143
446k
      if (*n == 0) {
144
280k
  break;
145
280k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
23.6k
  have = true;
147
23.6k
  break;
148
23.6k
      }
149
142k
      n = &(*n)->next;
150
142k
    }
151
303k
    return iterator(table_ + pos, n);
152
303k
  }
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&)
Line
Count
Source
138
951k
  {
139
951k
    Size pos = parms_.hash(to_find) % table_size_;
140
951k
    Node * * n = table_ + pos;
141
951k
    have = false;
142
1.47M
    while (true) {
143
1.47M
      if (*n == 0) {
144
47.0k
  break;
145
1.42M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
904k
  have = true;
147
904k
  break;
148
904k
      }
149
524k
      n = &(*n)->next;
150
524k
    }
151
951k
    return iterator(table_ + pos, n);
152
951k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::find_i(char const* const&, bool&)
Line
Count
Source
138
17.3M
  {
139
17.3M
    Size pos = parms_.hash(to_find) % table_size_;
140
17.3M
    Node * * n = table_ + pos;
141
17.3M
    have = false;
142
18.1M
    while (true) {
143
18.1M
      if (*n == 0) {
144
17.2M
  break;
145
17.2M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
112k
  have = true;
147
112k
  break;
148
112k
      }
149
720k
      n = &(*n)->next;
150
720k
    }
151
17.3M
    return iterator(table_ + pos, n);
152
17.3M
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::find_i(char const* const&, bool&)
Line
Count
Source
138
1.41M
  {
139
1.41M
    Size pos = parms_.hash(to_find) % table_size_;
140
1.41M
    Node * * n = table_ + pos;
141
1.41M
    have = false;
142
1.99M
    while (true) {
143
1.99M
      if (*n == 0) {
144
945k
  break;
145
1.04M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
473k
  have = true;
147
473k
  break;
148
473k
      }
149
572k
      n = &(*n)->next;
150
572k
    }
151
1.41M
    return iterator(table_ + pos, n);
152
1.41M
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::find_i(char const* const&, bool&)
Line
Count
Source
138
23.4M
  {
139
23.4M
    Size pos = parms_.hash(to_find) % table_size_;
140
23.4M
    Node * * n = table_ + pos;
141
23.4M
    have = false;
142
23.4M
    while (true) {
143
23.4M
      if (*n == 0) {
144
23.4M
  break;
145
23.4M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
0
  have = true;
147
0
  break;
148
0
      }
149
0
      n = &(*n)->next;
150
0
    }
151
23.4M
    return iterator(table_ + pos, n);
152
23.4M
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::find_i(char const* const&, bool&)
153
154
  template <class P>
155
  std::pair<typename HashTable<P>::iterator, typename HashTable<P>::iterator>
156
  HashTable<P>::equal_range_i(const Key & to_find, int & c)
157
23.4M
  {
158
23.4M
    c = 0;
159
23.4M
    bool have;
160
23.4M
    iterator first = find_i(to_find,have);
161
23.4M
    if (!have)
162
23.4M
      return std::pair<iterator,iterator>(end(),end());
163
0
    iterator last = first;
164
0
    c = 1;
165
0
    ++last;
166
0
    iterator e = end();
167
0
    while (!(last == e) && parms_.equal(parms_.key(*last), to_find)) {
168
0
      ++c;
169
0
      ++last;
170
0
    }
171
0
    return std::pair<iterator,iterator>(first,last);
172
23.4M
  }
173
174
  template <class P>
175
  void HashTable<P>::del() 
176
89.1k
  {
177
6.02M
    for (Node * * i = table_; i != table_end_; ++i) {
178
5.94M
      Node * n = *i;
179
7.87M
      while (n != 0) {
180
1.93M
  n->data.~Value();
181
1.93M
  n = n->next;
182
1.93M
      }
183
5.94M
    }
184
89.1k
    free (table_);
185
89.1k
    size_ = 0;
186
89.1k
    node_pool_.clear();
187
89.1k
    table_ = 0;
188
89.1k
    table_size_ = 0;
189
89.1k
    prime_index_ = 0;
190
89.1k
  }
acommon::HashTable<acommon::StringMap::Parms>::del()
Line
Count
Source
176
63.7k
  {
177
3.98M
    for (Node * * i = table_; i != table_end_; ++i) {
178
3.92M
      Node * n = *i;
179
4.89M
      while (n != 0) {
180
965k
  n->data.~Value();
181
965k
  n = n->next;
182
965k
      }
183
3.92M
    }
184
63.7k
    free (table_);
185
63.7k
    size_ = 0;
186
63.7k
    node_pool_.clear();
187
63.7k
    table_ = 0;
188
63.7k
    table_size_ = 0;
189
63.7k
    prime_index_ = 0;
190
63.7k
  }
acommon::HashTable<aspeller::CondsLookupParms>::del()
Line
Count
Source
176
1.02k
  {
177
66.9k
    for (Node * * i = table_; i != table_end_; ++i) {
178
65.9k
      Node * n = *i;
179
89.4k
      while (n != 0) {
180
23.4k
  n->data.~Value();
181
23.4k
  n = n->next;
182
23.4k
      }
183
65.9k
    }
184
1.02k
    free (table_);
185
1.02k
    size_ = 0;
186
1.02k
    node_pool_.clear();
187
1.02k
    table_ = 0;
188
1.02k
    table_size_ = 0;
189
1.02k
    prime_index_ = 0;
190
1.02k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
340
  {
177
31.7k
    for (Node * * i = table_; i != table_end_; ++i) {
178
31.3k
      Node * n = *i;
179
41.5k
      while (n != 0) {
180
10.2k
  n->data.~Value();
181
10.2k
  n = n->next;
182
10.2k
      }
183
31.3k
    }
184
340
    free (table_);
185
340
    size_ = 0;
186
340
    node_pool_.clear();
187
340
    table_ = 0;
188
340
    table_size_ = 0;
189
340
    prime_index_ = 0;
190
340
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del()
Line
Count
Source
176
17.9k
  {
177
1.61M
    for (Node * * i = table_; i != table_end_; ++i) {
178
1.59M
      Node * n = *i;
179
2.52M
      while (n != 0) {
180
934k
  n->data.~Value();
181
934k
  n = n->next;
182
934k
      }
183
1.59M
    }
184
17.9k
    free (table_);
185
17.9k
    size_ = 0;
186
17.9k
    node_pool_.clear();
187
17.9k
    table_ = 0;
188
17.9k
    table_size_ = 0;
189
17.9k
    prime_index_ = 0;
190
17.9k
  }
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
3.05k
  {
177
165k
    for (Node * * i = table_; i != table_end_; ++i) {
178
162k
      Node * n = *i;
179
162k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
162k
    }
184
3.05k
    free (table_);
185
3.05k
    size_ = 0;
186
3.05k
    node_pool_.clear();
187
3.05k
    table_ = 0;
188
3.05k
    table_size_ = 0;
189
3.05k
    prime_index_ = 0;
190
3.05k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del()
Line
Count
Source
176
3.05k
  {
177
165k
    for (Node * * i = table_; i != table_end_; ++i) {
178
162k
      Node * n = *i;
179
162k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
162k
    }
184
3.05k
    free (table_);
185
3.05k
    size_ = 0;
186
3.05k
    node_pool_.clear();
187
3.05k
    table_ = 0;
188
3.05k
    table_size_ = 0;
189
3.05k
    prime_index_ = 0;
190
3.05k
  }
191
192
  template <class P>
193
  void HashTable<P>::resize_i(PrimeIndex new_prime_index) 
194
11.1k
  {
195
11.1k
    Node * * old_table = table_;
196
11.1k
    Node * * old_end = table_end_;
197
11.1k
    Size old_size = table_size_;
198
11.1k
    create_table(new_prime_index);
199
779k
    for (Node * * i = old_table; i != old_end; ++i) {
200
768k
      Node * n = *i;
201
1.53M
      while (n != 0) {
202
768k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
768k
  Node * tmp = n;
204
768k
  n = n->next;
205
768k
  tmp->next = *put_me_here;
206
768k
  *put_me_here = tmp;
207
768k
      }
208
768k
    }
209
11.1k
    free(old_table);
210
11.1k
    node_pool_.add_block(table_size_ - old_size);
211
11.1k
  }
acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int)
Line
Count
Source
194
510
  {
195
510
    Node * * old_table = table_;
196
510
    Node * * old_end = table_end_;
197
510
    Size old_size = table_size_;
198
510
    create_table(new_prime_index);
199
30.3k
    for (Node * * i = old_table; i != old_end; ++i) {
200
29.8k
      Node * n = *i;
201
59.7k
      while (n != 0) {
202
29.8k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
29.8k
  Node * tmp = n;
204
29.8k
  n = n->next;
205
29.8k
  tmp->next = *put_me_here;
206
29.8k
  *put_me_here = tmp;
207
29.8k
      }
208
29.8k
    }
209
510
    free(old_table);
210
510
    node_pool_.add_block(table_size_ - old_size);
211
510
  }
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int)
Line
Count
Source
194
102
  {
195
102
    Node * * old_table = table_;
196
102
    Node * * old_end = table_end_;
197
102
    Size old_size = table_size_;
198
102
    create_table(new_prime_index);
199
11.7k
    for (Node * * i = old_table; i != old_end; ++i) {
200
11.6k
      Node * n = *i;
201
23.3k
      while (n != 0) {
202
11.6k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
11.6k
  Node * tmp = n;
204
11.6k
  n = n->next;
205
11.6k
  tmp->next = *put_me_here;
206
11.6k
  *put_me_here = tmp;
207
11.6k
      }
208
11.6k
    }
209
102
    free(old_table);
210
102
    node_pool_.add_block(table_size_ - old_size);
211
102
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::resize_i(unsigned int)
Line
Count
Source
194
48
  {
195
48
    Node * * old_table = table_;
196
48
    Node * * old_end = table_end_;
197
48
    Size old_size = table_size_;
198
48
    create_table(new_prime_index);
199
13.5k
    for (Node * * i = old_table; i != old_end; ++i) {
200
13.4k
      Node * n = *i;
201
26.9k
      while (n != 0) {
202
13.4k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
13.4k
  Node * tmp = n;
204
13.4k
  n = n->next;
205
13.4k
  tmp->next = *put_me_here;
206
13.4k
  *put_me_here = tmp;
207
13.4k
      }
208
13.4k
    }
209
48
    free(old_table);
210
48
    node_pool_.add_block(table_size_ - old_size);
211
48
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::resize_i(unsigned int)
Line
Count
Source
194
10.4k
  {
195
10.4k
    Node * * old_table = table_;
196
10.4k
    Node * * old_end = table_end_;
197
10.4k
    Size old_size = table_size_;
198
10.4k
    create_table(new_prime_index);
199
723k
    for (Node * * i = old_table; i != old_end; ++i) {
200
713k
      Node * n = *i;
201
1.42M
      while (n != 0) {
202
713k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
713k
  Node * tmp = n;
204
713k
  n = n->next;
205
713k
  tmp->next = *put_me_here;
206
713k
  *put_me_here = tmp;
207
713k
      }
208
713k
    }
209
10.4k
    free(old_table);
210
10.4k
    node_pool_.add_block(table_size_ - old_size);
211
10.4k
  }
Unexecuted instantiation: writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::resize_i(unsigned int)
Unexecuted instantiation: acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::resize_i(unsigned int)
212
213
  template <class P>
214
  void HashTable<P>::copy(const HashTable & other) 
215
20.5k
  {
216
20.5k
    init(other.prime_index_);
217
20.5k
    size_  = other.size_;
218
20.5k
    parms_ = other.parms_;
219
1.63M
    for (unsigned int i = 0; i != other.table_size_; ++i) {
220
2.55M
      for (Node * j = other.table_[i]; j != 0; j = j->next) {
221
938k
  Node * n = node_pool_.new_node();
222
938k
  new 
223
938k
    (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) 
224
938k
    Value(j->data);
225
938k
  n->next = table_[i];
226
938k
  table_[i] = n;
227
938k
      }
228
1.61M
    }
229
20.5k
  }
230
231
}
232
233
234
#endif