Coverage Report

Created: 2026-01-13 06:34

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.3k
  {
64
19.3k
    PrimeIndex i = prime_index_;
65
19.3k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
19.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
465
  {
64
465
    PrimeIndex i = prime_index_;
65
465
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
465
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::next_largest(unsigned int)
Line
Count
Source
63
13.2k
  {
64
13.2k
    PrimeIndex i = prime_index_;
65
13.2k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
13.2k
  }
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
2.80k
  {
64
2.80k
    PrimeIndex i = prime_index_;
65
2.80k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
2.80k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int)
Line
Count
Source
63
2.80k
  {
64
2.80k
    PrimeIndex i = prime_index_;
65
2.80k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
2.80k
  }
68
69
  template <class P>
70
99.9k
  void HashTable<P>::create_table(PrimeIndex i) {
71
99.9k
    prime_index_ = i;
72
99.9k
    table_size_ = primes[prime_index_];
73
99.9k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
99.9k
    table_end_ = table_ + table_size_;
75
99.9k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
99.9k
  }
acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int)
Line
Count
Source
70
71.1k
  void HashTable<P>::create_table(PrimeIndex i) {
71
71.1k
    prime_index_ = i;
72
71.1k
    table_size_ = primes[prime_index_];
73
71.1k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
71.1k
    table_end_ = table_ + table_size_;
75
71.1k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
71.1k
  }
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int)
Line
Count
Source
70
994
  void HashTable<P>::create_table(PrimeIndex i) {
71
994
    prime_index_ = i;
72
994
    table_size_ = primes[prime_index_];
73
994
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
994
    table_end_ = table_ + table_size_;
75
994
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
994
  }
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
598
  void HashTable<P>::create_table(PrimeIndex i) {
71
598
    prime_index_ = i;
72
598
    table_size_ = primes[prime_index_];
73
598
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
598
    table_end_ = table_ + table_size_;
75
598
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
598
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int)
Line
Count
Source
70
21.6k
  void HashTable<P>::create_table(PrimeIndex i) {
71
21.6k
    prime_index_ = i;
72
21.6k
    table_size_ = primes[prime_index_];
73
21.6k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
21.6k
    table_end_ = table_ + table_size_;
75
21.6k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
21.6k
  }
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
2.80k
  void HashTable<P>::create_table(PrimeIndex i) {
71
2.80k
    prime_index_ = i;
72
2.80k
    table_size_ = primes[prime_index_];
73
2.80k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
2.80k
    table_end_ = table_ + table_size_;
75
2.80k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
2.80k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int)
Line
Count
Source
70
2.80k
  void HashTable<P>::create_table(PrimeIndex i) {
71
2.80k
    prime_index_ = i;
72
2.80k
    table_size_ = primes[prime_index_];
73
2.80k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
2.80k
    table_end_ = table_ + table_size_;
75
2.80k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
2.80k
  }
77
78
  template <class P>
79
  void HashTable<P>::init(PrimeIndex i)
80
90.8k
  {
81
90.8k
    size_ = 0;
82
90.8k
    create_table(i);
83
90.8k
    node_pool_.add_block(primes[i]);
84
90.8k
  }
acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int)
Line
Count
Source
80
70.6k
  {
81
70.6k
    size_ = 0;
82
70.6k
    create_table(i);
83
70.6k
    node_pool_.add_block(primes[i]);
84
70.6k
  }
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int)
Line
Count
Source
80
940
  {
81
940
    size_ = 0;
82
940
    create_table(i);
83
940
    node_pool_.add_block(primes[i]);
84
940
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
Line
Count
Source
80
465
  {
81
465
    size_ = 0;
82
465
    create_table(i);
83
465
    node_pool_.add_block(primes[i]);
84
465
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int)
Line
Count
Source
80
13.2k
  {
81
13.2k
    size_ = 0;
82
13.2k
    create_table(i);
83
13.2k
    node_pool_.add_block(primes[i]);
84
13.2k
  }
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
2.80k
  {
81
2.80k
    size_ = 0;
82
2.80k
    create_table(i);
83
2.80k
    node_pool_.add_block(primes[i]);
84
2.80k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int)
Line
Count
Source
80
2.80k
  {
81
2.80k
    size_ = 0;
82
2.80k
    create_table(i);
83
2.80k
    node_pool_.add_block(primes[i]);
84
2.80k
  }
85
86
  template <class P>
87
  std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert)
88
1.57M
  {
89
1.57M
    bool have;
90
1.57M
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
1.57M
    if (have && !parms_.is_multi) 
92
671k
      return std::pair<iterator,bool>(put_me_here,false);
93
903k
    Node * new_node = node_pool_.new_node();
94
903k
    if (new_node == 0) {
95
9.07k
      resize_i(prime_index_+1);
96
9.07k
      return insert(to_insert);
97
9.07k
    }
98
894k
    new 
99
894k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
894k
      Value(to_insert);
101
894k
    new_node->next = *put_me_here.n;
102
894k
    *put_me_here.n = new_node;
103
894k
    ++size_;
104
894k
    return std::pair<iterator,bool>(put_me_here,true);
105
903k
  }
acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&)
Line
Count
Source
88
54.8k
  {
89
54.8k
    bool have;
90
54.8k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
54.8k
    if (have && !parms_.is_multi) 
92
15.4k
      return std::pair<iterator,bool>(put_me_here,false);
93
39.4k
    Node * new_node = node_pool_.new_node();
94
39.4k
    if (new_node == 0) {
95
489
      resize_i(prime_index_+1);
96
489
      return insert(to_insert);
97
489
    }
98
38.9k
    new 
99
38.9k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
38.9k
      Value(to_insert);
101
38.9k
    new_node->next = *put_me_here.n;
102
38.9k
    *put_me_here.n = new_node;
103
38.9k
    ++size_;
104
38.9k
    return std::pair<iterator,bool>(put_me_here,true);
105
39.4k
  }
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&)
Line
Count
Source
88
17.6k
  {
89
17.6k
    bool have;
90
17.6k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
17.6k
    if (have && !parms_.is_multi) 
92
0
      return std::pair<iterator,bool>(put_me_here,false);
93
17.6k
    Node * new_node = node_pool_.new_node();
94
17.6k
    if (new_node == 0) {
95
54
      resize_i(prime_index_+1);
96
54
      return insert(to_insert);
97
54
    }
98
17.5k
    new 
99
17.5k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
17.5k
      Value(to_insert);
101
17.5k
    new_node->next = *put_me_here.n;
102
17.5k
    *put_me_here.n = new_node;
103
17.5k
    ++size_;
104
17.5k
    return std::pair<iterator,bool>(put_me_here,true);
105
17.6k
  }
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
311k
  {
89
311k
    bool have;
90
311k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
311k
    if (have && !parms_.is_multi) 
92
285k
      return std::pair<iterator,bool>(put_me_here,false);
93
26.0k
    Node * new_node = node_pool_.new_node();
94
26.0k
    if (new_node == 0) {
95
133
      resize_i(prime_index_+1);
96
133
      return insert(to_insert);
97
133
    }
98
25.9k
    new 
99
25.9k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
25.9k
      Value(to_insert);
101
25.9k
    new_node->next = *put_me_here.n;
102
25.9k
    *put_me_here.n = new_node;
103
25.9k
    ++size_;
104
25.9k
    return std::pair<iterator,bool>(put_me_here,true);
105
26.0k
  }
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.19M
  {
89
1.19M
    bool have;
90
1.19M
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
1.19M
    if (have && !parms_.is_multi) 
92
370k
      return std::pair<iterator,bool>(put_me_here,false);
93
820k
    Node * new_node = node_pool_.new_node();
94
820k
    if (new_node == 0) {
95
8.39k
      resize_i(prime_index_+1);
96
8.39k
      return insert(to_insert);
97
8.39k
    }
98
811k
    new 
99
811k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
811k
      Value(to_insert);
101
811k
    new_node->next = *put_me_here.n;
102
811k
    *put_me_here.n = new_node;
103
811k
    ++size_;
104
811k
    return std::pair<iterator,bool>(put_me_here,true);
105
820k
  }
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
1.03k
  {
120
1.03k
    Size num_erased = 0;
121
1.03k
    bool irrelevant;
122
1.03k
    Node * * first = find_i(k,irrelevant).n;
123
1.03k
    Node * n = *first;
124
1.14k
    while (n != 0 && parms_.equal(parms_.key(n->data), k)) {
125
110
      Node * tmp = n;
126
110
      n->data.~Value();
127
110
      n = n->next;
128
110
      node_pool_.remove_node(tmp);
129
110
      ++num_erased;
130
110
    }
131
1.03k
    *first = n;
132
1.03k
    size_ -= num_erased;
133
1.03k
    return num_erased;
134
1.03k
  }
135
  
136
  template <class P>
137
  typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have)
138
43.7M
  {
139
43.7M
    Size pos = parms_.hash(to_find) % table_size_;
140
43.7M
    Node * * n = table_ + pos;
141
43.7M
    have = false;
142
46.7M
    while (true) {
143
46.7M
      if (*n == 0) {
144
42.3M
  break;
145
42.3M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
1.34M
  have = true;
147
1.34M
  break;
148
1.34M
      }
149
3.01M
      n = &(*n)->next;
150
3.01M
    }
151
43.7M
    return iterator(table_ + pos, n);
152
43.7M
  }
acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&)
Line
Count
Source
138
469k
  {
139
469k
    Size pos = parms_.hash(to_find) % table_size_;
140
469k
    Node * * n = table_ + pos;
141
469k
    have = false;
142
569k
    while (true) {
143
569k
      if (*n == 0) {
144
298k
  break;
145
298k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
170k
  have = true;
147
170k
  break;
148
170k
      }
149
100k
      n = &(*n)->next;
150
100k
    }
151
469k
    return iterator(table_ + pos, n);
152
469k
  }
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&)
Line
Count
Source
138
528k
  {
139
528k
    Size pos = parms_.hash(to_find) % table_size_;
140
528k
    Node * * n = table_ + pos;
141
528k
    have = false;
142
808k
    while (true) {
143
808k
      if (*n == 0) {
144
35.1k
  break;
145
773k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
493k
  have = true;
147
493k
  break;
148
493k
      }
149
280k
      n = &(*n)->next;
150
280k
    }
151
528k
    return iterator(table_ + pos, n);
152
528k
  }
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
23.9M
  {
139
23.9M
    Size pos = parms_.hash(to_find) % table_size_;
140
23.9M
    Node * * n = table_ + pos;
141
23.9M
    have = false;
142
26.0M
    while (true) {
143
26.0M
      if (*n == 0) {
144
23.6M
  break;
145
23.6M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
311k
  have = true;
147
311k
  break;
148
311k
      }
149
2.11M
      n = &(*n)->next;
150
2.11M
    }
151
23.9M
    return iterator(table_ + pos, n);
152
23.9M
  }
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.19M
  {
139
1.19M
    Size pos = parms_.hash(to_find) % table_size_;
140
1.19M
    Node * * n = table_ + pos;
141
1.19M
    have = false;
142
1.71M
    while (true) {
143
1.71M
      if (*n == 0) {
144
820k
  break;
145
896k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
370k
  have = true;
147
370k
  break;
148
370k
      }
149
525k
      n = &(*n)->next;
150
525k
    }
151
1.19M
    return iterator(table_ + pos, n);
152
1.19M
  }
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
17.5M
  {
139
17.5M
    Size pos = parms_.hash(to_find) % table_size_;
140
17.5M
    Node * * n = table_ + pos;
141
17.5M
    have = false;
142
17.5M
    while (true) {
143
17.5M
      if (*n == 0) {
144
17.5M
  break;
145
17.5M
      } 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
17.5M
    return iterator(table_ + pos, n);
152
17.5M
  }
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
17.5M
  {
158
17.5M
    c = 0;
159
17.5M
    bool have;
160
17.5M
    iterator first = find_i(to_find,have);
161
17.5M
    if (!have)
162
17.5M
      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
17.5M
  }
173
174
  template <class P>
175
  void HashTable<P>::del() 
176
90.6k
  {
177
6.23M
    for (Node * * i = table_; i != table_end_; ++i) {
178
6.14M
      Node * n = *i;
179
8.05M
      while (n != 0) {
180
1.91M
  n->data.~Value();
181
1.91M
  n = n->next;
182
1.91M
      }
183
6.14M
    }
184
90.6k
    free (table_);
185
90.6k
    size_ = 0;
186
90.6k
    node_pool_.clear();
187
90.6k
    table_ = 0;
188
90.6k
    table_size_ = 0;
189
90.6k
    prime_index_ = 0;
190
90.6k
  }
acommon::HashTable<acommon::StringMap::Parms>::del()
Line
Count
Source
176
70.4k
  {
177
4.42M
    for (Node * * i = table_; i != table_end_; ++i) {
178
4.35M
      Node * n = *i;
179
5.40M
      while (n != 0) {
180
1.05M
  n->data.~Value();
181
1.05M
  n = n->next;
182
1.05M
      }
183
4.35M
    }
184
70.4k
    free (table_);
185
70.4k
    size_ = 0;
186
70.4k
    node_pool_.clear();
187
70.4k
    table_ = 0;
188
70.4k
    table_size_ = 0;
189
70.4k
    prime_index_ = 0;
190
70.4k
  }
acommon::HashTable<aspeller::CondsLookupParms>::del()
Line
Count
Source
176
940
  {
177
56.8k
    for (Node * * i = table_; i != table_end_; ++i) {
178
55.8k
      Node * n = *i;
179
73.4k
      while (n != 0) {
180
17.5k
  n->data.~Value();
181
17.5k
  n = n->next;
182
17.5k
      }
183
55.8k
    }
184
940
    free (table_);
185
940
    size_ = 0;
186
940
    node_pool_.clear();
187
940
    table_ = 0;
188
940
    table_size_ = 0;
189
940
    prime_index_ = 0;
190
940
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
465
  {
177
56.0k
    for (Node * * i = table_; i != table_end_; ++i) {
178
55.5k
      Node * n = *i;
179
81.4k
      while (n != 0) {
180
25.9k
  n->data.~Value();
181
25.9k
  n = n->next;
182
25.9k
      }
183
55.5k
    }
184
465
    free (table_);
185
465
    size_ = 0;
186
465
    node_pool_.clear();
187
465
    table_ = 0;
188
465
    table_size_ = 0;
189
465
    prime_index_ = 0;
190
465
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del()
Line
Count
Source
176
13.2k
  {
177
1.39M
    for (Node * * i = table_; i != table_end_; ++i) {
178
1.38M
      Node * n = *i;
179
2.19M
      while (n != 0) {
180
811k
  n->data.~Value();
181
811k
  n = n->next;
182
811k
      }
183
1.38M
    }
184
13.2k
    free (table_);
185
13.2k
    size_ = 0;
186
13.2k
    node_pool_.clear();
187
13.2k
    table_ = 0;
188
13.2k
    table_size_ = 0;
189
13.2k
    prime_index_ = 0;
190
13.2k
  }
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
2.80k
  {
177
151k
    for (Node * * i = table_; i != table_end_; ++i) {
178
148k
      Node * n = *i;
179
148k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
148k
    }
184
2.80k
    free (table_);
185
2.80k
    size_ = 0;
186
2.80k
    node_pool_.clear();
187
2.80k
    table_ = 0;
188
2.80k
    table_size_ = 0;
189
2.80k
    prime_index_ = 0;
190
2.80k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del()
Line
Count
Source
176
2.80k
  {
177
151k
    for (Node * * i = table_; i != table_end_; ++i) {
178
148k
      Node * n = *i;
179
148k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
148k
    }
184
2.80k
    free (table_);
185
2.80k
    size_ = 0;
186
2.80k
    node_pool_.clear();
187
2.80k
    table_ = 0;
188
2.80k
    table_size_ = 0;
189
2.80k
    prime_index_ = 0;
190
2.80k
  }
191
192
  template <class P>
193
  void HashTable<P>::resize_i(PrimeIndex new_prime_index) 
194
9.07k
  {
195
9.07k
    Node * * old_table = table_;
196
9.07k
    Node * * old_end = table_end_;
197
9.07k
    Size old_size = table_size_;
198
9.07k
    create_table(new_prime_index);
199
807k
    for (Node * * i = old_table; i != old_end; ++i) {
200
798k
      Node * n = *i;
201
1.59M
      while (n != 0) {
202
798k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
798k
  Node * tmp = n;
204
798k
  n = n->next;
205
798k
  tmp->next = *put_me_here;
206
798k
  *put_me_here = tmp;
207
798k
      }
208
798k
    }
209
9.07k
    free(old_table);
210
9.07k
    node_pool_.add_block(table_size_ - old_size);
211
9.07k
  }
acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int)
Line
Count
Source
194
489
  {
195
489
    Node * * old_table = table_;
196
489
    Node * * old_end = table_end_;
197
489
    Size old_size = table_size_;
198
489
    create_table(new_prime_index);
199
29.5k
    for (Node * * i = old_table; i != old_end; ++i) {
200
29.1k
      Node * n = *i;
201
58.2k
      while (n != 0) {
202
29.1k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
29.1k
  Node * tmp = n;
204
29.1k
  n = n->next;
205
29.1k
  tmp->next = *put_me_here;
206
29.1k
  *put_me_here = tmp;
207
29.1k
      }
208
29.1k
    }
209
489
    free(old_table);
210
489
    node_pool_.add_block(table_size_ - old_size);
211
489
  }
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int)
Line
Count
Source
194
54
  {
195
54
    Node * * old_table = table_;
196
54
    Node * * old_end = table_end_;
197
54
    Size old_size = table_size_;
198
54
    create_table(new_prime_index);
199
6.22k
    for (Node * * i = old_table; i != old_end; ++i) {
200
6.17k
      Node * n = *i;
201
12.3k
      while (n != 0) {
202
6.17k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
6.17k
  Node * tmp = n;
204
6.17k
  n = n->next;
205
6.17k
  tmp->next = *put_me_here;
206
6.17k
  *put_me_here = tmp;
207
6.17k
      }
208
6.17k
    }
209
54
    free(old_table);
210
54
    node_pool_.add_block(table_size_ - old_size);
211
54
  }
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
133
  {
195
133
    Node * * old_table = table_;
196
133
    Node * * old_end = table_end_;
197
133
    Size old_size = table_size_;
198
133
    create_table(new_prime_index);
199
31.4k
    for (Node * * i = old_table; i != old_end; ++i) {
200
31.3k
      Node * n = *i;
201
62.6k
      while (n != 0) {
202
31.3k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
31.3k
  Node * tmp = n;
204
31.3k
  n = n->next;
205
31.3k
  tmp->next = *put_me_here;
206
31.3k
  *put_me_here = tmp;
207
31.3k
      }
208
31.3k
    }
209
133
    free(old_table);
210
133
    node_pool_.add_block(table_size_ - old_size);
211
133
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::resize_i(unsigned int)
Line
Count
Source
194
8.39k
  {
195
8.39k
    Node * * old_table = table_;
196
8.39k
    Node * * old_end = table_end_;
197
8.39k
    Size old_size = table_size_;
198
8.39k
    create_table(new_prime_index);
199
739k
    for (Node * * i = old_table; i != old_end; ++i) {
200
731k
      Node * n = *i;
201
1.46M
      while (n != 0) {
202
731k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
731k
  Node * tmp = n;
204
731k
  n = n->next;
205
731k
  tmp->next = *put_me_here;
206
731k
  *put_me_here = tmp;
207
731k
      }
208
731k
    }
209
8.39k
    free(old_table);
210
8.39k
    node_pool_.add_block(table_size_ - old_size);
211
8.39k
  }
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
22.7k
  {
216
22.7k
    init(other.prime_index_);
217
22.7k
    size_  = other.size_;
218
22.7k
    parms_ = other.parms_;
219
1.83M
    for (unsigned int i = 0; i != other.table_size_; ++i) {
220
2.84M
      for (Node * j = other.table_[i]; j != 0; j = j->next) {
221
1.02M
  Node * n = node_pool_.new_node();
222
1.02M
  new 
223
1.02M
    (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) 
224
1.02M
    Value(j->data);
225
1.02M
  n->next = table_[i];
226
1.02M
  table_[i] = n;
227
1.02M
      }
228
1.81M
    }
229
22.7k
  }
230
231
}
232
233
234
#endif