Coverage Report

Created: 2025-11-11 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aspell/common/hash-t.hpp
Line
Count
Source
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
19.0k
  {
64
19.0k
    PrimeIndex i = prime_index_;
65
19.0k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
19.0k
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::next_largest(unsigned int)
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::next_largest(unsigned int)
Line
Count
Source
63
12.8k
  {
64
12.8k
    PrimeIndex i = prime_index_;
65
12.8k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
12.8k
  }
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.11k
  {
64
3.11k
    PrimeIndex i = prime_index_;
65
3.11k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.11k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int)
Line
Count
Source
63
3.11k
  {
64
3.11k
    PrimeIndex i = prime_index_;
65
3.11k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.11k
  }
68
69
  template <class P>
70
93.2k
  void HashTable<P>::create_table(PrimeIndex i) {
71
93.2k
    prime_index_ = i;
72
93.2k
    table_size_ = primes[prime_index_];
73
93.2k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
93.2k
    table_end_ = table_ + table_size_;
75
93.2k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
93.2k
  }
acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int)
Line
Count
Source
70
65.2k
  void HashTable<P>::create_table(PrimeIndex i) {
71
65.2k
    prime_index_ = i;
72
65.2k
    table_size_ = primes[prime_index_];
73
65.2k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
65.2k
    table_end_ = table_ + table_size_;
75
65.2k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
65.2k
  }
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int)
Line
Count
Source
70
1.16k
  void HashTable<P>::create_table(PrimeIndex i) {
71
1.16k
    prime_index_ = i;
72
1.16k
    table_size_ = primes[prime_index_];
73
1.16k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
1.16k
    table_end_ = table_ + table_size_;
75
1.16k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
1.16k
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::create_table(unsigned int)
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int)
Line
Count
Source
70
20.5k
  void HashTable<P>::create_table(PrimeIndex i) {
71
20.5k
    prime_index_ = i;
72
20.5k
    table_size_ = primes[prime_index_];
73
20.5k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
20.5k
    table_end_ = table_ + table_size_;
75
20.5k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
20.5k
  }
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.11k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.11k
    prime_index_ = i;
72
3.11k
    table_size_ = primes[prime_index_];
73
3.11k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.11k
    table_end_ = table_ + table_size_;
75
3.11k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.11k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int)
Line
Count
Source
70
3.11k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.11k
    prime_index_ = i;
72
3.11k
    table_size_ = primes[prime_index_];
73
3.11k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.11k
    table_end_ = table_ + table_size_;
75
3.11k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.11k
  }
77
78
  template <class P>
79
  void HashTable<P>::init(PrimeIndex i)
80
84.9k
  {
81
84.9k
    size_ = 0;
82
84.9k
    create_table(i);
83
84.9k
    node_pool_.add_block(primes[i]);
84
84.9k
  }
acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int)
Line
Count
Source
80
64.7k
  {
81
64.7k
    size_ = 0;
82
64.7k
    create_table(i);
83
64.7k
    node_pool_.add_block(primes[i]);
84
64.7k
  }
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int)
Line
Count
Source
80
1.04k
  {
81
1.04k
    size_ = 0;
82
1.04k
    create_table(i);
83
1.04k
    node_pool_.add_block(primes[i]);
84
1.04k
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int)
Line
Count
Source
80
12.8k
  {
81
12.8k
    size_ = 0;
82
12.8k
    create_table(i);
83
12.8k
    node_pool_.add_block(primes[i]);
84
12.8k
  }
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.11k
  {
81
3.11k
    size_ = 0;
82
3.11k
    create_table(i);
83
3.11k
    node_pool_.add_block(primes[i]);
84
3.11k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int)
Line
Count
Source
80
3.11k
  {
81
3.11k
    size_ = 0;
82
3.11k
    create_table(i);
83
3.11k
    node_pool_.add_block(primes[i]);
84
3.11k
  }
85
86
  template <class P>
87
  std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert)
88
992k
  {
89
992k
    bool have;
90
992k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
992k
    if (have && !parms_.is_multi) 
92
295k
      return std::pair<iterator,bool>(put_me_here,false);
93
697k
    Node * new_node = node_pool_.new_node();
94
697k
    if (new_node == 0) {
95
8.29k
      resize_i(prime_index_+1);
96
8.29k
      return insert(to_insert);
97
8.29k
    }
98
689k
    new 
99
689k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
689k
      Value(to_insert);
101
689k
    new_node->next = *put_me_here.n;
102
689k
    *put_me_here.n = new_node;
103
689k
    ++size_;
104
689k
    return std::pair<iterator,bool>(put_me_here,true);
105
697k
  }
acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&)
Line
Count
Source
88
56.0k
  {
89
56.0k
    bool have;
90
56.0k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
56.0k
    if (have && !parms_.is_multi) 
92
14.1k
      return std::pair<iterator,bool>(put_me_here,false);
93
41.8k
    Node * new_node = node_pool_.new_node();
94
41.8k
    if (new_node == 0) {
95
511
      resize_i(prime_index_+1);
96
511
      return insert(to_insert);
97
511
    }
98
41.3k
    new 
99
41.3k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
41.3k
      Value(to_insert);
101
41.3k
    new_node->next = *put_me_here.n;
102
41.3k
    *put_me_here.n = new_node;
103
41.3k
    ++size_;
104
41.3k
    return std::pair<iterator,bool>(put_me_here,true);
105
41.8k
  }
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&)
Line
Count
Source
88
25.8k
  {
89
25.8k
    bool have;
90
25.8k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
25.8k
    if (have && !parms_.is_multi) 
92
0
      return std::pair<iterator,bool>(put_me_here,false);
93
25.8k
    Node * new_node = node_pool_.new_node();
94
25.8k
    if (new_node == 0) {
95
123
      resize_i(prime_index_+1);
96
123
      return insert(to_insert);
97
123
    }
98
25.7k
    new 
99
25.7k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
25.7k
      Value(to_insert);
101
25.7k
    new_node->next = *put_me_here.n;
102
25.7k
    *put_me_here.n = new_node;
103
25.7k
    ++size_;
104
25.7k
    return std::pair<iterator,bool>(put_me_here,true);
105
25.8k
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::insert(char const* const&)
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&)
Line
Count
Source
88
911k
  {
89
911k
    bool have;
90
911k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
911k
    if (have && !parms_.is_multi) 
92
280k
      return std::pair<iterator,bool>(put_me_here,false);
93
630k
    Node * new_node = node_pool_.new_node();
94
630k
    if (new_node == 0) {
95
7.66k
      resize_i(prime_index_+1);
96
7.66k
      return insert(to_insert);
97
7.66k
    }
98
622k
    new 
99
622k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
622k
      Value(to_insert);
101
622k
    new_node->next = *put_me_here.n;
102
622k
    *put_me_here.n = new_node;
103
622k
    ++size_;
104
622k
    return std::pair<iterator,bool>(put_me_here,true);
105
630k
  }
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
587
  {
120
587
    Size num_erased = 0;
121
587
    bool irrelevant;
122
587
    Node * * first = find_i(k,irrelevant).n;
123
587
    Node * n = *first;
124
686
    while (n != 0 && parms_.equal(parms_.key(n->data), k)) {
125
99
      Node * tmp = n;
126
99
      n->data.~Value();
127
99
      n = n->next;
128
99
      node_pool_.remove_node(tmp);
129
99
      ++num_erased;
130
99
    }
131
587
    *first = n;
132
587
    size_ -= num_erased;
133
587
    return num_erased;
134
587
  }
135
  
136
  template <class P>
137
  typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have)
138
16.2M
  {
139
16.2M
    Size pos = parms_.hash(to_find) % table_size_;
140
16.2M
    Node * * n = table_ + pos;
141
16.2M
    have = false;
142
17.3M
    while (true) {
143
17.3M
      if (*n == 0) {
144
14.8M
  break;
145
14.8M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
1.39M
  have = true;
147
1.39M
  break;
148
1.39M
      }
149
1.11M
      n = &(*n)->next;
150
1.11M
    }
151
16.2M
    return iterator(table_ + pos, n);
152
16.2M
  }
acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&)
Line
Count
Source
138
281k
  {
139
281k
    Size pos = parms_.hash(to_find) % table_size_;
140
281k
    Node * * n = table_ + pos;
141
281k
    have = false;
142
400k
    while (true) {
143
400k
      if (*n == 0) {
144
254k
  break;
145
254k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
27.4k
  have = true;
147
27.4k
  break;
148
27.4k
      }
149
118k
      n = &(*n)->next;
150
118k
    }
151
281k
    return iterator(table_ + pos, n);
152
281k
  }
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&)
Line
Count
Source
138
1.13M
  {
139
1.13M
    Size pos = parms_.hash(to_find) % table_size_;
140
1.13M
    Node * * n = table_ + pos;
141
1.13M
    have = false;
142
1.76M
    while (true) {
143
1.76M
      if (*n == 0) {
144
51.5k
  break;
145
1.71M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
1.08M
  have = true;
147
1.08M
  break;
148
1.08M
      }
149
630k
      n = &(*n)->next;
150
630k
    }
151
1.13M
    return iterator(table_ + pos, n);
152
1.13M
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::find_i(char const* const&, bool&)
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
911k
  {
139
911k
    Size pos = parms_.hash(to_find) % table_size_;
140
911k
    Node * * n = table_ + pos;
141
911k
    have = false;
142
1.27M
    while (true) {
143
1.27M
      if (*n == 0) {
144
630k
  break;
145
643k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
280k
  have = true;
147
280k
  break;
148
280k
      }
149
362k
      n = &(*n)->next;
150
362k
    }
151
911k
    return iterator(table_ + pos, n);
152
911k
  }
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
13.9M
  {
139
13.9M
    Size pos = parms_.hash(to_find) % table_size_;
140
13.9M
    Node * * n = table_ + pos;
141
13.9M
    have = false;
142
13.9M
    while (true) {
143
13.9M
      if (*n == 0) {
144
13.9M
  break;
145
13.9M
      } 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
13.9M
    return iterator(table_ + pos, n);
152
13.9M
  }
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
13.9M
  {
158
13.9M
    c = 0;
159
13.9M
    bool have;
160
13.9M
    iterator first = find_i(to_find,have);
161
13.9M
    if (!have)
162
13.9M
      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
13.9M
  }
173
174
  template <class P>
175
  void HashTable<P>::del() 
176
84.7k
  {
177
5.59M
    for (Node * * i = table_; i != table_end_; ++i) {
178
5.50M
      Node * n = *i;
179
7.12M
      while (n != 0) {
180
1.62M
  n->data.~Value();
181
1.62M
  n = n->next;
182
1.62M
      }
183
5.50M
    }
184
84.7k
    free (table_);
185
84.7k
    size_ = 0;
186
84.7k
    node_pool_.clear();
187
84.7k
    table_ = 0;
188
84.7k
    table_size_ = 0;
189
84.7k
    prime_index_ = 0;
190
84.7k
  }
acommon::HashTable<acommon::StringMap::Parms>::del()
Line
Count
Source
176
64.5k
  {
177
4.03M
    for (Node * * i = table_; i != table_end_; ++i) {
178
3.97M
      Node * n = *i;
179
4.95M
      while (n != 0) {
180
975k
  n->data.~Value();
181
975k
  n = n->next;
182
975k
      }
183
3.97M
    }
184
64.5k
    free (table_);
185
64.5k
    size_ = 0;
186
64.5k
    node_pool_.clear();
187
64.5k
    table_ = 0;
188
64.5k
    table_size_ = 0;
189
64.5k
    prime_index_ = 0;
190
64.5k
  }
acommon::HashTable<aspeller::CondsLookupParms>::del()
Line
Count
Source
176
1.04k
  {
177
70.0k
    for (Node * * i = table_; i != table_end_; ++i) {
178
69.0k
      Node * n = *i;
179
94.7k
      while (n != 0) {
180
25.7k
  n->data.~Value();
181
25.7k
  n = n->next;
182
25.7k
      }
183
69.0k
    }
184
1.04k
    free (table_);
185
1.04k
    size_ = 0;
186
1.04k
    node_pool_.clear();
187
1.04k
    table_ = 0;
188
1.04k
    table_size_ = 0;
189
1.04k
    prime_index_ = 0;
190
1.04k
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del()
Line
Count
Source
176
12.8k
  {
177
1.14M
    for (Node * * i = table_; i != table_end_; ++i) {
178
1.13M
      Node * n = *i;
179
1.75M
      while (n != 0) {
180
622k
  n->data.~Value();
181
622k
  n = n->next;
182
622k
      }
183
1.13M
    }
184
12.8k
    free (table_);
185
12.8k
    size_ = 0;
186
12.8k
    node_pool_.clear();
187
12.8k
    table_ = 0;
188
12.8k
    table_size_ = 0;
189
12.8k
    prime_index_ = 0;
190
12.8k
  }
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.11k
  {
177
168k
    for (Node * * i = table_; i != table_end_; ++i) {
178
165k
      Node * n = *i;
179
165k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
165k
    }
184
3.11k
    free (table_);
185
3.11k
    size_ = 0;
186
3.11k
    node_pool_.clear();
187
3.11k
    table_ = 0;
188
3.11k
    table_size_ = 0;
189
3.11k
    prime_index_ = 0;
190
3.11k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del()
Line
Count
Source
176
3.11k
  {
177
168k
    for (Node * * i = table_; i != table_end_; ++i) {
178
165k
      Node * n = *i;
179
165k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
165k
    }
184
3.11k
    free (table_);
185
3.11k
    size_ = 0;
186
3.11k
    node_pool_.clear();
187
3.11k
    table_ = 0;
188
3.11k
    table_size_ = 0;
189
3.11k
    prime_index_ = 0;
190
3.11k
  }
191
192
  template <class P>
193
  void HashTable<P>::resize_i(PrimeIndex new_prime_index) 
194
8.29k
  {
195
8.29k
    Node * * old_table = table_;
196
8.29k
    Node * * old_end = table_end_;
197
8.29k
    Size old_size = table_size_;
198
8.29k
    create_table(new_prime_index);
199
554k
    for (Node * * i = old_table; i != old_end; ++i) {
200
545k
      Node * n = *i;
201
1.09M
      while (n != 0) {
202
545k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
545k
  Node * tmp = n;
204
545k
  n = n->next;
205
545k
  tmp->next = *put_me_here;
206
545k
  *put_me_here = tmp;
207
545k
      }
208
545k
    }
209
8.29k
    free(old_table);
210
8.29k
    node_pool_.add_block(table_size_ - old_size);
211
8.29k
  }
acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int)
Line
Count
Source
194
511
  {
195
511
    Node * * old_table = table_;
196
511
    Node * * old_end = table_end_;
197
511
    Size old_size = table_size_;
198
511
    create_table(new_prime_index);
199
30.2k
    for (Node * * i = old_table; i != old_end; ++i) {
200
29.7k
      Node * n = *i;
201
59.4k
      while (n != 0) {
202
29.7k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
29.7k
  Node * tmp = n;
204
29.7k
  n = n->next;
205
29.7k
  tmp->next = *put_me_here;
206
29.7k
  *put_me_here = tmp;
207
29.7k
      }
208
29.7k
    }
209
511
    free(old_table);
210
511
    node_pool_.add_block(table_size_ - old_size);
211
511
  }
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int)
Line
Count
Source
194
123
  {
195
123
    Node * * old_table = table_;
196
123
    Node * * old_end = table_end_;
197
123
    Size old_size = table_size_;
198
123
    create_table(new_prime_index);
199
14.1k
    for (Node * * i = old_table; i != old_end; ++i) {
200
14.0k
      Node * n = *i;
201
28.1k
      while (n != 0) {
202
14.0k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
14.0k
  Node * tmp = n;
204
14.0k
  n = n->next;
205
14.0k
  tmp->next = *put_me_here;
206
14.0k
  *put_me_here = tmp;
207
14.0k
      }
208
14.0k
    }
209
123
    free(old_table);
210
123
    node_pool_.add_block(table_size_ - old_size);
211
123
  }
Unexecuted instantiation: acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::resize_i(unsigned int)
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::resize_i(unsigned int)
Line
Count
Source
194
7.66k
  {
195
7.66k
    Node * * old_table = table_;
196
7.66k
    Node * * old_end = table_end_;
197
7.66k
    Size old_size = table_size_;
198
7.66k
    create_table(new_prime_index);
199
509k
    for (Node * * i = old_table; i != old_end; ++i) {
200
502k
      Node * n = *i;
201
1.00M
      while (n != 0) {
202
502k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
502k
  Node * tmp = n;
204
502k
  n = n->next;
205
502k
  tmp->next = *put_me_here;
206
502k
  *put_me_here = tmp;
207
502k
      }
208
502k
    }
209
7.66k
    free(old_table);
210
7.66k
    node_pool_.add_block(table_size_ - old_size);
211
7.66k
  }
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.7k
  {
216
20.7k
    init(other.prime_index_);
217
20.7k
    size_  = other.size_;
218
20.7k
    parms_ = other.parms_;
219
1.65M
    for (unsigned int i = 0; i != other.table_size_; ++i) {
220
2.58M
      for (Node * j = other.table_[i]; j != 0; j = j->next) {
221
946k
  Node * n = node_pool_.new_node();
222
946k
  new 
223
946k
    (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) 
224
946k
    Value(j->data);
225
946k
  n->next = table_[i];
226
946k
  table_[i] = n;
227
946k
      }
228
1.63M
    }
229
20.7k
  }
230
231
}
232
233
234
#endif