Coverage Report

Created: 2026-09-14 06:16

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
11.1k
  {
64
11.1k
    PrimeIndex i = prime_index_;
65
11.1k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
11.1k
  }
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
40
  {
64
40
    PrimeIndex i = prime_index_;
65
40
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
40
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::next_largest(unsigned int)
Line
Count
Source
63
6.92k
  {
64
6.92k
    PrimeIndex i = prime_index_;
65
6.92k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
6.92k
  }
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.07k
  {
64
2.07k
    PrimeIndex i = prime_index_;
65
2.07k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
2.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int)
Line
Count
Source
63
2.07k
  {
64
2.07k
    PrimeIndex i = prime_index_;
65
2.07k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
2.07k
  }
68
69
  template <class P>
70
48.5k
  void HashTable<P>::create_table(PrimeIndex i) {
71
48.5k
    prime_index_ = i;
72
48.5k
    table_size_ = primes[prime_index_];
73
48.5k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
48.5k
    table_end_ = table_ + table_size_;
75
48.5k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
48.5k
  }
acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int)
Line
Count
Source
70
30.3k
  void HashTable<P>::create_table(PrimeIndex i) {
71
30.3k
    prime_index_ = i;
72
30.3k
    table_size_ = primes[prime_index_];
73
30.3k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
30.3k
    table_end_ = table_ + table_size_;
75
30.3k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
30.3k
  }
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int)
Line
Count
Source
70
742
  void HashTable<P>::create_table(PrimeIndex i) {
71
742
    prime_index_ = i;
72
742
    table_size_ = primes[prime_index_];
73
742
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
742
    table_end_ = table_ + table_size_;
75
742
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
742
  }
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
42
  void HashTable<P>::create_table(PrimeIndex i) {
71
42
    prime_index_ = i;
72
42
    table_size_ = primes[prime_index_];
73
42
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
42
    table_end_ = table_ + table_size_;
75
42
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
42
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int)
Line
Count
Source
70
13.3k
  void HashTable<P>::create_table(PrimeIndex i) {
71
13.3k
    prime_index_ = i;
72
13.3k
    table_size_ = primes[prime_index_];
73
13.3k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
13.3k
    table_end_ = table_ + table_size_;
75
13.3k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
13.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
2.07k
  void HashTable<P>::create_table(PrimeIndex i) {
71
2.07k
    prime_index_ = i;
72
2.07k
    table_size_ = primes[prime_index_];
73
2.07k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
2.07k
    table_end_ = table_ + table_size_;
75
2.07k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
2.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int)
Line
Count
Source
70
2.07k
  void HashTable<P>::create_table(PrimeIndex i) {
71
2.07k
    prime_index_ = i;
72
2.07k
    table_size_ = primes[prime_index_];
73
2.07k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
2.07k
    table_end_ = table_ + table_size_;
75
2.07k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
2.07k
  }
77
78
  template <class P>
79
  void HashTable<P>::init(PrimeIndex i)
80
41.7k
  {
81
41.7k
    size_ = 0;
82
41.7k
    create_table(i);
83
41.7k
    node_pool_.add_block(primes[i]);
84
41.7k
  }
acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int)
Line
Count
Source
80
29.9k
  {
81
29.9k
    size_ = 0;
82
29.9k
    create_table(i);
83
29.9k
    node_pool_.add_block(primes[i]);
84
29.9k
  }
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int)
Line
Count
Source
80
691
  {
81
691
    size_ = 0;
82
691
    create_table(i);
83
691
    node_pool_.add_block(primes[i]);
84
691
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
Line
Count
Source
80
40
  {
81
40
    size_ = 0;
82
40
    create_table(i);
83
40
    node_pool_.add_block(primes[i]);
84
40
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int)
Line
Count
Source
80
6.92k
  {
81
6.92k
    size_ = 0;
82
6.92k
    create_table(i);
83
6.92k
    node_pool_.add_block(primes[i]);
84
6.92k
  }
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.07k
  {
81
2.07k
    size_ = 0;
82
2.07k
    create_table(i);
83
2.07k
    node_pool_.add_block(primes[i]);
84
2.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int)
Line
Count
Source
80
2.07k
  {
81
2.07k
    size_ = 0;
82
2.07k
    create_table(i);
83
2.07k
    node_pool_.add_block(primes[i]);
84
2.07k
  }
85
86
  template <class P>
87
  std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert)
88
685k
  {
89
685k
    bool have;
90
685k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
685k
    if (have && !parms_.is_multi) 
92
178k
      return std::pair<iterator,bool>(put_me_here,false);
93
507k
    Node * new_node = node_pool_.new_node();
94
507k
    if (new_node == 0) {
95
6.81k
      resize_i(prime_index_+1);
96
6.81k
      return insert(to_insert);
97
6.81k
    }
98
500k
    new 
99
500k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
500k
      Value(to_insert);
101
500k
    new_node->next = *put_me_here.n;
102
500k
    *put_me_here.n = new_node;
103
500k
    ++size_;
104
500k
    return std::pair<iterator,bool>(put_me_here,true);
105
507k
  }
acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&)
Line
Count
Source
88
38.4k
  {
89
38.4k
    bool have;
90
38.4k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
38.4k
    if (have && !parms_.is_multi) 
92
8.87k
      return std::pair<iterator,bool>(put_me_here,false);
93
29.5k
    Node * new_node = node_pool_.new_node();
94
29.5k
    if (new_node == 0) {
95
374
      resize_i(prime_index_+1);
96
374
      return insert(to_insert);
97
374
    }
98
29.1k
    new 
99
29.1k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
29.1k
      Value(to_insert);
101
29.1k
    new_node->next = *put_me_here.n;
102
29.1k
    *put_me_here.n = new_node;
103
29.1k
    ++size_;
104
29.1k
    return std::pair<iterator,bool>(put_me_here,true);
105
29.5k
  }
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&)
Line
Count
Source
88
14.0k
  {
89
14.0k
    bool have;
90
14.0k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
14.0k
    if (have && !parms_.is_multi) 
92
0
      return std::pair<iterator,bool>(put_me_here,false);
93
14.0k
    Node * new_node = node_pool_.new_node();
94
14.0k
    if (new_node == 0) {
95
51
      resize_i(prime_index_+1);
96
51
      return insert(to_insert);
97
51
    }
98
14.0k
    new 
99
14.0k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
14.0k
      Value(to_insert);
101
14.0k
    new_node->next = *put_me_here.n;
102
14.0k
    *put_me_here.n = new_node;
103
14.0k
    ++size_;
104
14.0k
    return std::pair<iterator,bool>(put_me_here,true);
105
14.0k
  }
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
593
  {
89
593
    bool have;
90
593
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
593
    if (have && !parms_.is_multi) 
92
371
      return std::pair<iterator,bool>(put_me_here,false);
93
222
    Node * new_node = node_pool_.new_node();
94
222
    if (new_node == 0) {
95
2
      resize_i(prime_index_+1);
96
2
      return insert(to_insert);
97
2
    }
98
220
    new 
99
220
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
220
      Value(to_insert);
101
220
    new_node->next = *put_me_here.n;
102
220
    *put_me_here.n = new_node;
103
220
    ++size_;
104
220
    return std::pair<iterator,bool>(put_me_here,true);
105
222
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&)
Line
Count
Source
88
632k
  {
89
632k
    bool have;
90
632k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
632k
    if (have && !parms_.is_multi) 
92
169k
      return std::pair<iterator,bool>(put_me_here,false);
93
463k
    Node * new_node = node_pool_.new_node();
94
463k
    if (new_node == 0) {
95
6.38k
      resize_i(prime_index_+1);
96
6.38k
      return insert(to_insert);
97
6.38k
    }
98
457k
    new 
99
457k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
457k
      Value(to_insert);
101
457k
    new_node->next = *put_me_here.n;
102
457k
    *put_me_here.n = new_node;
103
457k
    ++size_;
104
457k
    return std::pair<iterator,bool>(put_me_here,true);
105
463k
  }
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.01k
  {
120
1.01k
    Size num_erased = 0;
121
1.01k
    bool irrelevant;
122
1.01k
    Node * * first = find_i(k,irrelevant).n;
123
1.01k
    Node * n = *first;
124
1.09k
    while (n != 0 && parms_.equal(parms_.key(n->data), k)) {
125
84
      Node * tmp = n;
126
84
      n->data.~Value();
127
84
      n = n->next;
128
84
      node_pool_.remove_node(tmp);
129
84
      ++num_erased;
130
84
    }
131
1.01k
    *first = n;
132
1.01k
    size_ -= num_erased;
133
1.01k
    return num_erased;
134
1.01k
  }
135
  
136
  template <class P>
137
  typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have)
138
10.7M
  {
139
10.7M
    Size pos = parms_.hash(to_find) % table_size_;
140
10.7M
    Node * * n = table_ + pos;
141
10.7M
    have = false;
142
11.5M
    while (true) {
143
11.5M
      if (*n == 0) {
144
10.1M
  break;
145
10.1M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
648k
  have = true;
147
648k
  break;
148
648k
      }
149
781k
      n = &(*n)->next;
150
781k
    }
151
10.7M
    return iterator(table_ + pos, n);
152
10.7M
  }
acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&)
Line
Count
Source
138
251k
  {
139
251k
    Size pos = parms_.hash(to_find) % table_size_;
140
251k
    Node * * n = table_ + pos;
141
251k
    have = false;
142
367k
    while (true) {
143
367k
      if (*n == 0) {
144
230k
  break;
145
230k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
20.4k
  have = true;
147
20.4k
  break;
148
20.4k
      }
149
116k
      n = &(*n)->next;
150
116k
    }
151
251k
    return iterator(table_ + pos, n);
152
251k
  }
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&)
Line
Count
Source
138
486k
  {
139
486k
    Size pos = parms_.hash(to_find) % table_size_;
140
486k
    Node * * n = table_ + pos;
141
486k
    have = false;
142
750k
    while (true) {
143
750k
      if (*n == 0) {
144
28.1k
  break;
145
722k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
458k
  have = true;
147
458k
  break;
148
458k
      }
149
263k
      n = &(*n)->next;
150
263k
    }
151
486k
    return iterator(table_ + pos, n);
152
486k
  }
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
2.03M
  {
139
2.03M
    Size pos = parms_.hash(to_find) % table_size_;
140
2.03M
    Node * * n = table_ + pos;
141
2.03M
    have = false;
142
2.16M
    while (true) {
143
2.16M
      if (*n == 0) {
144
2.03M
  break;
145
2.03M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
587
  have = true;
147
587
  break;
148
587
      }
149
131k
      n = &(*n)->next;
150
131k
    }
151
2.03M
    return iterator(table_ + pos, n);
152
2.03M
  }
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
632k
  {
139
632k
    Size pos = parms_.hash(to_find) % table_size_;
140
632k
    Node * * n = table_ + pos;
141
632k
    have = false;
142
902k
    while (true) {
143
902k
      if (*n == 0) {
144
463k
  break;
145
463k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
169k
  have = true;
147
169k
  break;
148
169k
      }
149
269k
      n = &(*n)->next;
150
269k
    }
151
632k
    return iterator(table_ + pos, n);
152
632k
  }
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
7.35M
  {
139
7.35M
    Size pos = parms_.hash(to_find) % table_size_;
140
7.35M
    Node * * n = table_ + pos;
141
7.35M
    have = false;
142
7.35M
    while (true) {
143
7.35M
      if (*n == 0) {
144
7.35M
  break;
145
7.35M
      } 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
7.35M
    return iterator(table_ + pos, n);
152
7.35M
  }
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
7.35M
  {
158
7.35M
    c = 0;
159
7.35M
    bool have;
160
7.35M
    iterator first = find_i(to_find,have);
161
7.35M
    if (!have)
162
7.35M
      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
7.35M
  }
173
174
  template <class P>
175
  void HashTable<P>::del() 
176
41.6k
  {
177
2.88M
    for (Node * * i = table_; i != table_end_; ++i) {
178
2.83M
      Node * n = *i;
179
3.68M
      while (n != 0) {
180
843k
  n->data.~Value();
181
843k
  n = n->next;
182
843k
      }
183
2.83M
    }
184
41.6k
    free (table_);
185
41.6k
    size_ = 0;
186
41.6k
    node_pool_.clear();
187
41.6k
    table_ = 0;
188
41.6k
    table_size_ = 0;
189
41.6k
    prime_index_ = 0;
190
41.6k
  }
acommon::HashTable<acommon::StringMap::Parms>::del()
Line
Count
Source
176
29.8k
  {
177
1.81M
    for (Node * * i = table_; i != table_end_; ++i) {
178
1.78M
      Node * n = *i;
179
2.16M
      while (n != 0) {
180
372k
  n->data.~Value();
181
372k
  n = n->next;
182
372k
      }
183
1.78M
    }
184
29.8k
    free (table_);
185
29.8k
    size_ = 0;
186
29.8k
    node_pool_.clear();
187
29.8k
    table_ = 0;
188
29.8k
    table_size_ = 0;
189
29.8k
    prime_index_ = 0;
190
29.8k
  }
acommon::HashTable<aspeller::CondsLookupParms>::del()
Line
Count
Source
176
691
  {
177
43.0k
    for (Node * * i = table_; i != table_end_; ++i) {
178
42.3k
      Node * n = *i;
179
56.3k
      while (n != 0) {
180
14.0k
  n->data.~Value();
181
14.0k
  n = n->next;
182
14.0k
      }
183
42.3k
    }
184
691
    free (table_);
185
691
    size_ = 0;
186
691
    node_pool_.clear();
187
691
    table_ = 0;
188
691
    table_size_ = 0;
189
691
    prime_index_ = 0;
190
691
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
40
  {
177
2.30k
    for (Node * * i = table_; i != table_end_; ++i) {
178
2.26k
      Node * n = *i;
179
2.48k
      while (n != 0) {
180
220
  n->data.~Value();
181
220
  n = n->next;
182
220
      }
183
2.26k
    }
184
40
    free (table_);
185
40
    size_ = 0;
186
40
    node_pool_.clear();
187
40
    table_ = 0;
188
40
    table_size_ = 0;
189
40
    prime_index_ = 0;
190
40
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del()
Line
Count
Source
176
6.92k
  {
177
792k
    for (Node * * i = table_; i != table_end_; ++i) {
178
785k
      Node * n = *i;
179
1.24M
      while (n != 0) {
180
457k
  n->data.~Value();
181
457k
  n = n->next;
182
457k
      }
183
785k
    }
184
6.92k
    free (table_);
185
6.92k
    size_ = 0;
186
6.92k
    node_pool_.clear();
187
6.92k
    table_ = 0;
188
6.92k
    table_size_ = 0;
189
6.92k
    prime_index_ = 0;
190
6.92k
  }
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.07k
  {
177
111k
    for (Node * * i = table_; i != table_end_; ++i) {
178
109k
      Node * n = *i;
179
109k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
109k
    }
184
2.07k
    free (table_);
185
2.07k
    size_ = 0;
186
2.07k
    node_pool_.clear();
187
2.07k
    table_ = 0;
188
2.07k
    table_size_ = 0;
189
2.07k
    prime_index_ = 0;
190
2.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del()
Line
Count
Source
176
2.07k
  {
177
111k
    for (Node * * i = table_; i != table_end_; ++i) {
178
109k
      Node * n = *i;
179
109k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
109k
    }
184
2.07k
    free (table_);
185
2.07k
    size_ = 0;
186
2.07k
    node_pool_.clear();
187
2.07k
    table_ = 0;
188
2.07k
    table_size_ = 0;
189
2.07k
    prime_index_ = 0;
190
2.07k
  }
191
192
  template <class P>
193
  void HashTable<P>::resize_i(PrimeIndex new_prime_index) 
194
6.81k
  {
195
6.81k
    Node * * old_table = table_;
196
6.81k
    Node * * old_end = table_end_;
197
6.81k
    Size old_size = table_size_;
198
6.81k
    create_table(new_prime_index);
199
494k
    for (Node * * i = old_table; i != old_end; ++i) {
200
487k
      Node * n = *i;
201
975k
      while (n != 0) {
202
487k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
487k
  Node * tmp = n;
204
487k
  n = n->next;
205
487k
  tmp->next = *put_me_here;
206
487k
  *put_me_here = tmp;
207
487k
      }
208
487k
    }
209
6.81k
    free(old_table);
210
6.81k
    node_pool_.add_block(table_size_ - old_size);
211
6.81k
  }
acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int)
Line
Count
Source
194
374
  {
195
374
    Node * * old_table = table_;
196
374
    Node * * old_end = table_end_;
197
374
    Size old_size = table_size_;
198
374
    create_table(new_prime_index);
199
22.3k
    for (Node * * i = old_table; i != old_end; ++i) {
200
22.0k
      Node * n = *i;
201
44.0k
      while (n != 0) {
202
22.0k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
22.0k
  Node * tmp = n;
204
22.0k
  n = n->next;
205
22.0k
  tmp->next = *put_me_here;
206
22.0k
  *put_me_here = tmp;
207
22.0k
      }
208
22.0k
    }
209
374
    free(old_table);
210
374
    node_pool_.add_block(table_size_ - old_size);
211
374
  }
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int)
Line
Count
Source
194
51
  {
195
51
    Node * * old_table = table_;
196
51
    Node * * old_end = table_end_;
197
51
    Size old_size = table_size_;
198
51
    create_table(new_prime_index);
199
5.88k
    for (Node * * i = old_table; i != old_end; ++i) {
200
5.83k
      Node * n = *i;
201
11.6k
      while (n != 0) {
202
5.83k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
5.83k
  Node * tmp = n;
204
5.83k
  n = n->next;
205
5.83k
  tmp->next = *put_me_here;
206
5.83k
  *put_me_here = tmp;
207
5.83k
      }
208
5.83k
    }
209
51
    free(old_table);
210
51
    node_pool_.add_block(table_size_ - old_size);
211
51
  }
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
2
  {
195
2
    Node * * old_table = table_;
196
2
    Node * * old_end = table_end_;
197
2
    Size old_size = table_size_;
198
2
    create_table(new_prime_index);
199
152
    for (Node * * i = old_table; i != old_end; ++i) {
200
150
      Node * n = *i;
201
300
      while (n != 0) {
202
150
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
150
  Node * tmp = n;
204
150
  n = n->next;
205
150
  tmp->next = *put_me_here;
206
150
  *put_me_here = tmp;
207
150
      }
208
150
    }
209
2
    free(old_table);
210
2
    node_pool_.add_block(table_size_ - old_size);
211
2
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::resize_i(unsigned int)
Line
Count
Source
194
6.38k
  {
195
6.38k
    Node * * old_table = table_;
196
6.38k
    Node * * old_end = table_end_;
197
6.38k
    Size old_size = table_size_;
198
6.38k
    create_table(new_prime_index);
199
466k
    for (Node * * i = old_table; i != old_end; ++i) {
200
459k
      Node * n = *i;
201
919k
      while (n != 0) {
202
459k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
459k
  Node * tmp = n;
204
459k
  n = n->next;
205
459k
  tmp->next = *put_me_here;
206
459k
  *put_me_here = tmp;
207
459k
      }
208
459k
    }
209
6.38k
    free(old_table);
210
6.38k
    node_pool_.add_block(table_size_ - old_size);
211
6.38k
  }
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
9.31k
  {
216
9.31k
    init(other.prime_index_);
217
9.31k
    size_  = other.size_;
218
9.31k
    parms_ = other.parms_;
219
697k
    for (unsigned int i = 0; i != other.table_size_; ++i) {
220
1.03M
      for (Node * j = other.table_[i]; j != 0; j = j->next) {
221
350k
  Node * n = node_pool_.new_node();
222
350k
  new 
223
350k
    (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) 
224
350k
    Value(j->data);
225
350k
  n->next = table_[i];
226
350k
  table_[i] = n;
227
350k
      }
228
688k
    }
229
9.31k
  }
230
231
}
232
233
234
#endif