Coverage Report

Created: 2026-01-17 06:12

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
18.9k
  {
64
18.9k
    PrimeIndex i = prime_index_;
65
18.9k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
18.9k
  }
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
241
  {
64
241
    PrimeIndex i = prime_index_;
65
241
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
241
  }
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.5k
  {
64
12.5k
    PrimeIndex i = prime_index_;
65
12.5k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
12.5k
  }
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.07k
  {
64
3.07k
    PrimeIndex i = prime_index_;
65
3.07k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int)
Line
Count
Source
63
3.07k
  {
64
3.07k
    PrimeIndex i = prime_index_;
65
3.07k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.07k
  }
68
69
  template <class P>
70
113k
  void HashTable<P>::create_table(PrimeIndex i) {
71
113k
    prime_index_ = i;
72
113k
    table_size_ = primes[prime_index_];
73
113k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
113k
    table_end_ = table_ + table_size_;
75
113k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
113k
  }
acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int)
Line
Count
Source
70
86.3k
  void HashTable<P>::create_table(PrimeIndex i) {
71
86.3k
    prime_index_ = i;
72
86.3k
    table_size_ = primes[prime_index_];
73
86.3k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
86.3k
    table_end_ = table_ + table_size_;
75
86.3k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
86.3k
  }
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int)
Line
Count
Source
70
1.10k
  void HashTable<P>::create_table(PrimeIndex i) {
71
1.10k
    prime_index_ = i;
72
1.10k
    table_size_ = primes[prime_index_];
73
1.10k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
1.10k
    table_end_ = table_ + table_size_;
75
1.10k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
1.10k
  }
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
292
  void HashTable<P>::create_table(PrimeIndex i) {
71
292
    prime_index_ = i;
72
292
    table_size_ = primes[prime_index_];
73
292
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
292
    table_end_ = table_ + table_size_;
75
292
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
292
  }
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.0k
  void HashTable<P>::create_table(PrimeIndex i) {
71
20.0k
    prime_index_ = i;
72
20.0k
    table_size_ = primes[prime_index_];
73
20.0k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
20.0k
    table_end_ = table_ + table_size_;
75
20.0k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
20.0k
  }
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.07k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.07k
    prime_index_ = i;
72
3.07k
    table_size_ = primes[prime_index_];
73
3.07k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.07k
    table_end_ = table_ + table_size_;
75
3.07k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int)
Line
Count
Source
70
3.07k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.07k
    prime_index_ = i;
72
3.07k
    table_size_ = primes[prime_index_];
73
3.07k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.07k
    table_end_ = table_ + table_size_;
75
3.07k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.07k
  }
77
78
  template <class P>
79
  void HashTable<P>::init(PrimeIndex i)
80
105k
  {
81
105k
    size_ = 0;
82
105k
    create_table(i);
83
105k
    node_pool_.add_block(primes[i]);
84
105k
  }
acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int)
Line
Count
Source
80
85.7k
  {
81
85.7k
    size_ = 0;
82
85.7k
    create_table(i);
83
85.7k
    node_pool_.add_block(primes[i]);
84
85.7k
  }
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int)
Line
Count
Source
80
1.03k
  {
81
1.03k
    size_ = 0;
82
1.03k
    create_table(i);
83
1.03k
    node_pool_.add_block(primes[i]);
84
1.03k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
Line
Count
Source
80
241
  {
81
241
    size_ = 0;
82
241
    create_table(i);
83
241
    node_pool_.add_block(primes[i]);
84
241
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int)
Line
Count
Source
80
12.5k
  {
81
12.5k
    size_ = 0;
82
12.5k
    create_table(i);
83
12.5k
    node_pool_.add_block(primes[i]);
84
12.5k
  }
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.07k
  {
81
3.07k
    size_ = 0;
82
3.07k
    create_table(i);
83
3.07k
    node_pool_.add_block(primes[i]);
84
3.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int)
Line
Count
Source
80
3.07k
  {
81
3.07k
    size_ = 0;
82
3.07k
    create_table(i);
83
3.07k
    node_pool_.add_block(primes[i]);
84
3.07k
  }
85
86
  template <class P>
87
  std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert)
88
1.16M
  {
89
1.16M
    bool have;
90
1.16M
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
1.16M
    if (have && !parms_.is_multi) 
92
432k
      return std::pair<iterator,bool>(put_me_here,false);
93
731k
    Node * new_node = node_pool_.new_node();
94
731k
    if (new_node == 0) {
95
8.21k
      resize_i(prime_index_+1);
96
8.21k
      return insert(to_insert);
97
8.21k
    }
98
722k
    new 
99
722k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
722k
      Value(to_insert);
101
722k
    new_node->next = *put_me_here.n;
102
722k
    *put_me_here.n = new_node;
103
722k
    ++size_;
104
722k
    return std::pair<iterator,bool>(put_me_here,true);
105
731k
  }
acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&)
Line
Count
Source
88
61.7k
  {
89
61.7k
    bool have;
90
61.7k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
61.7k
    if (have && !parms_.is_multi) 
92
17.2k
      return std::pair<iterator,bool>(put_me_here,false);
93
44.5k
    Node * new_node = node_pool_.new_node();
94
44.5k
    if (new_node == 0) {
95
560
      resize_i(prime_index_+1);
96
560
      return insert(to_insert);
97
560
    }
98
43.9k
    new 
99
43.9k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
43.9k
      Value(to_insert);
101
43.9k
    new_node->next = *put_me_here.n;
102
43.9k
    *put_me_here.n = new_node;
103
43.9k
    ++size_;
104
43.9k
    return std::pair<iterator,bool>(put_me_here,true);
105
44.5k
  }
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&)
Line
Count
Source
88
20.9k
  {
89
20.9k
    bool have;
90
20.9k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
20.9k
    if (have && !parms_.is_multi) 
92
0
      return std::pair<iterator,bool>(put_me_here,false);
93
20.9k
    Node * new_node = node_pool_.new_node();
94
20.9k
    if (new_node == 0) {
95
75
      resize_i(prime_index_+1);
96
75
      return insert(to_insert);
97
75
    }
98
20.8k
    new 
99
20.8k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
20.8k
      Value(to_insert);
101
20.8k
    new_node->next = *put_me_here.n;
102
20.8k
    *put_me_here.n = new_node;
103
20.8k
    ++size_;
104
20.8k
    return std::pair<iterator,bool>(put_me_here,true);
105
20.9k
  }
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
94.4k
  {
89
94.4k
    bool have;
90
94.4k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
94.4k
    if (have && !parms_.is_multi) 
92
88.1k
      return std::pair<iterator,bool>(put_me_here,false);
93
6.33k
    Node * new_node = node_pool_.new_node();
94
6.33k
    if (new_node == 0) {
95
51
      resize_i(prime_index_+1);
96
51
      return insert(to_insert);
97
51
    }
98
6.28k
    new 
99
6.28k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
6.28k
      Value(to_insert);
101
6.28k
    new_node->next = *put_me_here.n;
102
6.28k
    *put_me_here.n = new_node;
103
6.28k
    ++size_;
104
6.28k
    return std::pair<iterator,bool>(put_me_here,true);
105
6.33k
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&)
Line
Count
Source
88
986k
  {
89
986k
    bool have;
90
986k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
986k
    if (have && !parms_.is_multi) 
92
327k
      return std::pair<iterator,bool>(put_me_here,false);
93
659k
    Node * new_node = node_pool_.new_node();
94
659k
    if (new_node == 0) {
95
7.53k
      resize_i(prime_index_+1);
96
7.53k
      return insert(to_insert);
97
7.53k
    }
98
651k
    new 
99
651k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
651k
      Value(to_insert);
101
651k
    new_node->next = *put_me_here.n;
102
651k
    *put_me_here.n = new_node;
103
651k
    ++size_;
104
651k
    return std::pair<iterator,bool>(put_me_here,true);
105
659k
  }
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
966
  {
120
966
    Size num_erased = 0;
121
966
    bool irrelevant;
122
966
    Node * * first = find_i(k,irrelevant).n;
123
966
    Node * n = *first;
124
1.06k
    while (n != 0 && parms_.equal(parms_.key(n->data), k)) {
125
101
      Node * tmp = n;
126
101
      n->data.~Value();
127
101
      n = n->next;
128
101
      node_pool_.remove_node(tmp);
129
101
      ++num_erased;
130
101
    }
131
966
    *first = n;
132
966
    size_ -= num_erased;
133
966
    return num_erased;
134
966
  }
135
  
136
  template <class P>
137
  typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have)
138
29.0M
  {
139
29.0M
    Size pos = parms_.hash(to_find) % table_size_;
140
29.0M
    Node * * n = table_ + pos;
141
29.0M
    have = false;
142
30.6M
    while (true) {
143
30.6M
      if (*n == 0) {
144
27.9M
  break;
145
27.9M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
1.15M
  have = true;
147
1.15M
  break;
148
1.15M
      }
149
1.56M
      n = &(*n)->next;
150
1.56M
    }
151
29.0M
    return iterator(table_ + pos, n);
152
29.0M
  }
acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&)
Line
Count
Source
138
322k
  {
139
322k
    Size pos = parms_.hash(to_find) % table_size_;
140
322k
    Node * * n = table_ + pos;
141
322k
    have = false;
142
424k
    while (true) {
143
424k
      if (*n == 0) {
144
265k
  break;
145
265k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
56.5k
  have = true;
147
56.5k
  break;
148
56.5k
      }
149
101k
      n = &(*n)->next;
150
101k
    }
151
322k
    return iterator(table_ + pos, n);
152
322k
  }
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&)
Line
Count
Source
138
717k
  {
139
717k
    Size pos = parms_.hash(to_find) % table_size_;
140
717k
    Node * * n = table_ + pos;
141
717k
    have = false;
142
1.10M
    while (true) {
143
1.10M
      if (*n == 0) {
144
41.7k
  break;
145
1.06M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
675k
  have = true;
147
675k
  break;
148
675k
      }
149
387k
      n = &(*n)->next;
150
387k
    }
151
717k
    return iterator(table_ + pos, n);
152
717k
  }
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
12.3M
  {
139
12.3M
    Size pos = parms_.hash(to_find) % table_size_;
140
12.3M
    Node * * n = table_ + pos;
141
12.3M
    have = false;
142
13.0M
    while (true) {
143
13.0M
      if (*n == 0) {
144
12.2M
  break;
145
12.2M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
94.4k
  have = true;
147
94.4k
  break;
148
94.4k
      }
149
683k
      n = &(*n)->next;
150
683k
    }
151
12.3M
    return iterator(table_ + pos, n);
152
12.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
986k
  {
139
986k
    Size pos = parms_.hash(to_find) % table_size_;
140
986k
    Node * * n = table_ + pos;
141
986k
    have = false;
142
1.37M
    while (true) {
143
1.37M
      if (*n == 0) {
144
659k
  break;
145
719k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
327k
  have = true;
147
327k
  break;
148
327k
      }
149
391k
      n = &(*n)->next;
150
391k
    }
151
986k
    return iterator(table_ + pos, n);
152
986k
  }
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
14.7M
  {
139
14.7M
    Size pos = parms_.hash(to_find) % table_size_;
140
14.7M
    Node * * n = table_ + pos;
141
14.7M
    have = false;
142
14.7M
    while (true) {
143
14.7M
      if (*n == 0) {
144
14.7M
  break;
145
14.7M
      } 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
14.7M
    return iterator(table_ + pos, n);
152
14.7M
  }
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
14.7M
  {
158
14.7M
    c = 0;
159
14.7M
    bool have;
160
14.7M
    iterator first = find_i(to_find,have);
161
14.7M
    if (!have)
162
14.7M
      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
14.7M
  }
173
174
  template <class P>
175
  void HashTable<P>::del() 
176
105k
  {
177
6.94M
    for (Node * * i = table_; i != table_end_; ++i) {
178
6.84M
      Node * n = *i;
179
8.82M
      while (n != 0) {
180
1.98M
  n->data.~Value();
181
1.98M
  n = n->next;
182
1.98M
      }
183
6.84M
    }
184
105k
    free (table_);
185
105k
    size_ = 0;
186
105k
    node_pool_.clear();
187
105k
    table_ = 0;
188
105k
    table_size_ = 0;
189
105k
    prime_index_ = 0;
190
105k
  }
acommon::HashTable<acommon::StringMap::Parms>::del()
Line
Count
Source
176
85.5k
  {
177
5.40M
    for (Node * * i = table_; i != table_end_; ++i) {
178
5.32M
      Node * n = *i;
179
6.62M
      while (n != 0) {
180
1.30M
  n->data.~Value();
181
1.30M
  n = n->next;
182
1.30M
      }
183
5.32M
    }
184
85.5k
    free (table_);
185
85.5k
    size_ = 0;
186
85.5k
    node_pool_.clear();
187
85.5k
    table_ = 0;
188
85.5k
    table_size_ = 0;
189
85.5k
    prime_index_ = 0;
190
85.5k
  }
acommon::HashTable<aspeller::CondsLookupParms>::del()
Line
Count
Source
176
1.03k
  {
177
64.1k
    for (Node * * i = table_; i != table_end_; ++i) {
178
63.1k
      Node * n = *i;
179
84.0k
      while (n != 0) {
180
20.8k
  n->data.~Value();
181
20.8k
  n = n->next;
182
20.8k
      }
183
63.1k
    }
184
1.03k
    free (table_);
185
1.03k
    size_ = 0;
186
1.03k
    node_pool_.clear();
187
1.03k
    table_ = 0;
188
1.03k
    table_size_ = 0;
189
1.03k
    prime_index_ = 0;
190
1.03k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
241
  {
177
21.6k
    for (Node * * i = table_; i != table_end_; ++i) {
178
21.3k
      Node * n = *i;
179
27.6k
      while (n != 0) {
180
6.28k
  n->data.~Value();
181
6.28k
  n = n->next;
182
6.28k
      }
183
21.3k
    }
184
241
    free (table_);
185
241
    size_ = 0;
186
241
    node_pool_.clear();
187
241
    table_ = 0;
188
241
    table_size_ = 0;
189
241
    prime_index_ = 0;
190
241
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del()
Line
Count
Source
176
12.5k
  {
177
1.12M
    for (Node * * i = table_; i != table_end_; ++i) {
178
1.11M
      Node * n = *i;
179
1.76M
      while (n != 0) {
180
651k
  n->data.~Value();
181
651k
  n = n->next;
182
651k
      }
183
1.11M
    }
184
12.5k
    free (table_);
185
12.5k
    size_ = 0;
186
12.5k
    node_pool_.clear();
187
12.5k
    table_ = 0;
188
12.5k
    table_size_ = 0;
189
12.5k
    prime_index_ = 0;
190
12.5k
  }
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.07k
  {
177
166k
    for (Node * * i = table_; i != table_end_; ++i) {
178
163k
      Node * n = *i;
179
163k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
163k
    }
184
3.07k
    free (table_);
185
3.07k
    size_ = 0;
186
3.07k
    node_pool_.clear();
187
3.07k
    table_ = 0;
188
3.07k
    table_size_ = 0;
189
3.07k
    prime_index_ = 0;
190
3.07k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del()
Line
Count
Source
176
3.07k
  {
177
166k
    for (Node * * i = table_; i != table_end_; ++i) {
178
163k
      Node * n = *i;
179
163k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
163k
    }
184
3.07k
    free (table_);
185
3.07k
    size_ = 0;
186
3.07k
    node_pool_.clear();
187
3.07k
    table_ = 0;
188
3.07k
    table_size_ = 0;
189
3.07k
    prime_index_ = 0;
190
3.07k
  }
191
192
  template <class P>
193
  void HashTable<P>::resize_i(PrimeIndex new_prime_index) 
194
8.21k
  {
195
8.21k
    Node * * old_table = table_;
196
8.21k
    Node * * old_end = table_end_;
197
8.21k
    Size old_size = table_size_;
198
8.21k
    create_table(new_prime_index);
199
559k
    for (Node * * i = old_table; i != old_end; ++i) {
200
551k
      Node * n = *i;
201
1.10M
      while (n != 0) {
202
551k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
551k
  Node * tmp = n;
204
551k
  n = n->next;
205
551k
  tmp->next = *put_me_here;
206
551k
  *put_me_here = tmp;
207
551k
      }
208
551k
    }
209
8.21k
    free(old_table);
210
8.21k
    node_pool_.add_block(table_size_ - old_size);
211
8.21k
  }
acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int)
Line
Count
Source
194
560
  {
195
560
    Node * * old_table = table_;
196
560
    Node * * old_end = table_end_;
197
560
    Size old_size = table_size_;
198
560
    create_table(new_prime_index);
199
33.7k
    for (Node * * i = old_table; i != old_end; ++i) {
200
33.2k
      Node * n = *i;
201
66.4k
      while (n != 0) {
202
33.2k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
33.2k
  Node * tmp = n;
204
33.2k
  n = n->next;
205
33.2k
  tmp->next = *put_me_here;
206
33.2k
  *put_me_here = tmp;
207
33.2k
      }
208
33.2k
    }
209
560
    free(old_table);
210
560
    node_pool_.add_block(table_size_ - old_size);
211
560
  }
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int)
Line
Count
Source
194
75
  {
195
75
    Node * * old_table = table_;
196
75
    Node * * old_end = table_end_;
197
75
    Size old_size = table_size_;
198
75
    create_table(new_prime_index);
199
8.65k
    for (Node * * i = old_table; i != old_end; ++i) {
200
8.57k
      Node * n = *i;
201
17.1k
      while (n != 0) {
202
8.57k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
8.57k
  Node * tmp = n;
204
8.57k
  n = n->next;
205
8.57k
  tmp->next = *put_me_here;
206
8.57k
  *put_me_here = tmp;
207
8.57k
      }
208
8.57k
    }
209
75
    free(old_table);
210
75
    node_pool_.add_block(table_size_ - old_size);
211
75
  }
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
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
8.84k
    for (Node * * i = old_table; i != old_end; ++i) {
200
8.79k
      Node * n = *i;
201
17.5k
      while (n != 0) {
202
8.79k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
8.79k
  Node * tmp = n;
204
8.79k
  n = n->next;
205
8.79k
  tmp->next = *put_me_here;
206
8.79k
  *put_me_here = tmp;
207
8.79k
      }
208
8.79k
    }
209
51
    free(old_table);
210
51
    node_pool_.add_block(table_size_ - old_size);
211
51
  }
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.53k
  {
195
7.53k
    Node * * old_table = table_;
196
7.53k
    Node * * old_end = table_end_;
197
7.53k
    Size old_size = table_size_;
198
7.53k
    create_table(new_prime_index);
199
508k
    for (Node * * i = old_table; i != old_end; ++i) {
200
500k
      Node * n = *i;
201
1.00M
      while (n != 0) {
202
500k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
500k
  Node * tmp = n;
204
500k
  n = n->next;
205
500k
  tmp->next = *put_me_here;
206
500k
  *put_me_here = tmp;
207
500k
      }
208
500k
    }
209
7.53k
    free(old_table);
210
7.53k
    node_pool_.add_block(table_size_ - old_size);
211
7.53k
  }
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
27.7k
  {
216
27.7k
    init(other.prime_index_);
217
27.7k
    size_  = other.size_;
218
27.7k
    parms_ = other.parms_;
219
2.26M
    for (unsigned int i = 0; i != other.table_size_; ++i) {
220
3.51M
      for (Node * j = other.table_[i]; j != 0; j = j->next) {
221
1.27M
  Node * n = node_pool_.new_node();
222
1.27M
  new 
223
1.27M
    (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) 
224
1.27M
    Value(j->data);
225
1.27M
  n->next = table_[i];
226
1.27M
  table_[i] = n;
227
1.27M
      }
228
2.23M
    }
229
27.7k
  }
230
231
}
232
233
234
#endif