Coverage Report

Created: 2026-08-13 06:28

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
15.6k
  {
64
15.6k
    PrimeIndex i = prime_index_;
65
15.6k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
15.6k
  }
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
44
  {
64
44
    PrimeIndex i = prime_index_;
65
44
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
44
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::next_largest(unsigned int)
Line
Count
Source
63
10.9k
  {
64
10.9k
    PrimeIndex i = prime_index_;
65
10.9k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
10.9k
  }
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::next_largest(unsigned int)
Line
Count
Source
63
2.28k
  {
64
2.28k
    PrimeIndex i = prime_index_;
65
2.28k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
2.28k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int)
Line
Count
Source
63
2.28k
  {
64
2.28k
    PrimeIndex i = prime_index_;
65
2.28k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
2.28k
  }
68
69
  template <class P>
70
65.9k
  void HashTable<P>::create_table(PrimeIndex i) {
71
65.9k
    prime_index_ = i;
72
65.9k
    table_size_ = primes[prime_index_];
73
65.9k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
65.9k
    table_end_ = table_ + table_size_;
75
65.9k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
65.9k
  }
acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int)
Line
Count
Source
70
42.6k
  void HashTable<P>::create_table(PrimeIndex i) {
71
42.6k
    prime_index_ = i;
72
42.6k
    table_size_ = primes[prime_index_];
73
42.6k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
42.6k
    table_end_ = table_ + table_size_;
75
42.6k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
42.6k
  }
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int)
Line
Count
Source
70
829
  void HashTable<P>::create_table(PrimeIndex i) {
71
829
    prime_index_ = i;
72
829
    table_size_ = primes[prime_index_];
73
829
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
829
    table_end_ = table_ + table_size_;
75
829
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
829
  }
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
49
  void HashTable<P>::create_table(PrimeIndex i) {
71
49
    prime_index_ = i;
72
49
    table_size_ = primes[prime_index_];
73
49
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
49
    table_end_ = table_ + table_size_;
75
49
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
49
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int)
Line
Count
Source
70
17.7k
  void HashTable<P>::create_table(PrimeIndex i) {
71
17.7k
    prime_index_ = i;
72
17.7k
    table_size_ = primes[prime_index_];
73
17.7k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
17.7k
    table_end_ = table_ + table_size_;
75
17.7k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
17.7k
  }
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.28k
  void HashTable<P>::create_table(PrimeIndex i) {
71
2.28k
    prime_index_ = i;
72
2.28k
    table_size_ = primes[prime_index_];
73
2.28k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
2.28k
    table_end_ = table_ + table_size_;
75
2.28k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
2.28k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int)
Line
Count
Source
70
2.28k
  void HashTable<P>::create_table(PrimeIndex i) {
71
2.28k
    prime_index_ = i;
72
2.28k
    table_size_ = primes[prime_index_];
73
2.28k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
2.28k
    table_end_ = table_ + table_size_;
75
2.28k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
2.28k
  }
77
78
  template <class P>
79
  void HashTable<P>::init(PrimeIndex i)
80
58.6k
  {
81
58.6k
    size_ = 0;
82
58.6k
    create_table(i);
83
58.6k
    node_pool_.add_block(primes[i]);
84
58.6k
  }
acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int)
Line
Count
Source
80
42.2k
  {
81
42.2k
    size_ = 0;
82
42.2k
    create_table(i);
83
42.2k
    node_pool_.add_block(primes[i]);
84
42.2k
  }
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int)
Line
Count
Source
80
766
  {
81
766
    size_ = 0;
82
766
    create_table(i);
83
766
    node_pool_.add_block(primes[i]);
84
766
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
Line
Count
Source
80
44
  {
81
44
    size_ = 0;
82
44
    create_table(i);
83
44
    node_pool_.add_block(primes[i]);
84
44
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::init(unsigned int)
Line
Count
Source
80
10.9k
  {
81
10.9k
    size_ = 0;
82
10.9k
    create_table(i);
83
10.9k
    node_pool_.add_block(primes[i]);
84
10.9k
  }
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::init(unsigned int)
Line
Count
Source
80
2.28k
  {
81
2.28k
    size_ = 0;
82
2.28k
    create_table(i);
83
2.28k
    node_pool_.add_block(primes[i]);
84
2.28k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int)
Line
Count
Source
80
2.28k
  {
81
2.28k
    size_ = 0;
82
2.28k
    create_table(i);
83
2.28k
    node_pool_.add_block(primes[i]);
84
2.28k
  }
85
86
  template <class P>
87
  std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert)
88
849k
  {
89
849k
    bool have;
90
849k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
849k
    if (have && !parms_.is_multi) 
92
262k
      return std::pair<iterator,bool>(put_me_here,false);
93
587k
    Node * new_node = node_pool_.new_node();
94
587k
    if (new_node == 0) {
95
7.27k
      resize_i(prime_index_+1);
96
7.27k
      return insert(to_insert);
97
7.27k
    }
98
579k
    new 
99
579k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
579k
      Value(to_insert);
101
579k
    new_node->next = *put_me_here.n;
102
579k
    *put_me_here.n = new_node;
103
579k
    ++size_;
104
579k
    return std::pair<iterator,bool>(put_me_here,true);
105
587k
  }
acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&)
Line
Count
Source
88
44.0k
  {
89
44.0k
    bool have;
90
44.0k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
44.0k
    if (have && !parms_.is_multi) 
92
11.2k
      return std::pair<iterator,bool>(put_me_here,false);
93
32.7k
    Node * new_node = node_pool_.new_node();
94
32.7k
    if (new_node == 0) {
95
408
      resize_i(prime_index_+1);
96
408
      return insert(to_insert);
97
408
    }
98
32.3k
    new 
99
32.3k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
32.3k
      Value(to_insert);
101
32.3k
    new_node->next = *put_me_here.n;
102
32.3k
    *put_me_here.n = new_node;
103
32.3k
    ++size_;
104
32.3k
    return std::pair<iterator,bool>(put_me_here,true);
105
32.7k
  }
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&)
Line
Count
Source
88
16.2k
  {
89
16.2k
    bool have;
90
16.2k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
16.2k
    if (have && !parms_.is_multi) 
92
0
      return std::pair<iterator,bool>(put_me_here,false);
93
16.2k
    Node * new_node = node_pool_.new_node();
94
16.2k
    if (new_node == 0) {
95
63
      resize_i(prime_index_+1);
96
63
      return insert(to_insert);
97
63
    }
98
16.1k
    new 
99
16.1k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
16.1k
      Value(to_insert);
101
16.1k
    new_node->next = *put_me_here.n;
102
16.1k
    *put_me_here.n = new_node;
103
16.1k
    ++size_;
104
16.1k
    return std::pair<iterator,bool>(put_me_here,true);
105
16.2k
  }
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
14.9k
  {
89
14.9k
    bool have;
90
14.9k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
14.9k
    if (have && !parms_.is_multi) 
92
13.4k
      return std::pair<iterator,bool>(put_me_here,false);
93
1.46k
    Node * new_node = node_pool_.new_node();
94
1.46k
    if (new_node == 0) {
95
5
      resize_i(prime_index_+1);
96
5
      return insert(to_insert);
97
5
    }
98
1.46k
    new 
99
1.46k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
1.46k
      Value(to_insert);
101
1.46k
    new_node->next = *put_me_here.n;
102
1.46k
    *put_me_here.n = new_node;
103
1.46k
    ++size_;
104
1.46k
    return std::pair<iterator,bool>(put_me_here,true);
105
1.46k
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&)
Line
Count
Source
88
773k
  {
89
773k
    bool have;
90
773k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
773k
    if (have && !parms_.is_multi) 
92
237k
      return std::pair<iterator,bool>(put_me_here,false);
93
536k
    Node * new_node = node_pool_.new_node();
94
536k
    if (new_node == 0) {
95
6.79k
      resize_i(prime_index_+1);
96
6.79k
      return insert(to_insert);
97
6.79k
    }
98
529k
    new 
99
529k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
529k
      Value(to_insert);
101
529k
    new_node->next = *put_me_here.n;
102
529k
    *put_me_here.n = new_node;
103
529k
    ++size_;
104
529k
    return std::pair<iterator,bool>(put_me_here,true);
105
536k
  }
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.05k
  {
120
1.05k
    Size num_erased = 0;
121
1.05k
    bool irrelevant;
122
1.05k
    Node * * first = find_i(k,irrelevant).n;
123
1.05k
    Node * n = *first;
124
1.11k
    while (n != 0 && parms_.equal(parms_.key(n->data), k)) {
125
68
      Node * tmp = n;
126
68
      n->data.~Value();
127
68
      n = n->next;
128
68
      node_pool_.remove_node(tmp);
129
68
      ++num_erased;
130
68
    }
131
1.05k
    *first = n;
132
1.05k
    size_ -= num_erased;
133
1.05k
    return num_erased;
134
1.05k
  }
135
  
136
  template <class P>
137
  typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have)
138
19.8M
  {
139
19.8M
    Size pos = parms_.hash(to_find) % table_size_;
140
19.8M
    Node * * n = table_ + pos;
141
19.8M
    have = false;
142
20.7M
    while (true) {
143
20.7M
      if (*n == 0) {
144
18.9M
  break;
145
18.9M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
846k
  have = true;
147
846k
  break;
148
846k
      }
149
919k
      n = &(*n)->next;
150
919k
    }
151
19.8M
    return iterator(table_ + pos, n);
152
19.8M
  }
acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&)
Line
Count
Source
138
261k
  {
139
261k
    Size pos = parms_.hash(to_find) % table_size_;
140
261k
    Node * * n = table_ + pos;
141
261k
    have = false;
142
383k
    while (true) {
143
383k
      if (*n == 0) {
144
230k
  break;
145
230k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
31.1k
  have = true;
147
31.1k
  break;
148
31.1k
      }
149
121k
      n = &(*n)->next;
150
121k
    }
151
261k
    return iterator(table_ + pos, n);
152
261k
  }
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&)
Line
Count
Source
138
595k
  {
139
595k
    Size pos = parms_.hash(to_find) % table_size_;
140
595k
    Node * * n = table_ + pos;
141
595k
    have = false;
142
920k
    while (true) {
143
920k
      if (*n == 0) {
144
32.4k
  break;
145
888k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
563k
  have = true;
147
563k
  break;
148
563k
      }
149
324k
      n = &(*n)->next;
150
324k
    }
151
595k
    return iterator(table_ + pos, n);
152
595k
  }
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.25M
  {
139
2.25M
    Size pos = parms_.hash(to_find) % table_size_;
140
2.25M
    Node * * n = table_ + pos;
141
2.25M
    have = false;
142
2.41M
    while (true) {
143
2.41M
      if (*n == 0) {
144
2.23M
  break;
145
2.23M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
14.9k
  have = true;
147
14.9k
  break;
148
14.9k
      }
149
167k
      n = &(*n)->next;
150
167k
    }
151
2.25M
    return iterator(table_ + pos, n);
152
2.25M
  }
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
773k
  {
139
773k
    Size pos = parms_.hash(to_find) % table_size_;
140
773k
    Node * * n = table_ + pos;
141
773k
    have = false;
142
1.07M
    while (true) {
143
1.07M
      if (*n == 0) {
144
536k
  break;
145
543k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
237k
  have = true;
147
237k
  break;
148
237k
      }
149
305k
      n = &(*n)->next;
150
305k
    }
151
773k
    return iterator(table_ + pos, n);
152
773k
  }
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
15.9M
  {
139
15.9M
    Size pos = parms_.hash(to_find) % table_size_;
140
15.9M
    Node * * n = table_ + pos;
141
15.9M
    have = false;
142
15.9M
    while (true) {
143
15.9M
      if (*n == 0) {
144
15.9M
  break;
145
15.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
15.9M
    return iterator(table_ + pos, n);
152
15.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
15.9M
  {
158
15.9M
    c = 0;
159
15.9M
    bool have;
160
15.9M
    iterator first = find_i(to_find,have);
161
15.9M
    if (!have)
162
15.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
15.9M
  }
173
174
  template <class P>
175
  void HashTable<P>::del() 
176
58.4k
  {
177
3.87M
    for (Node * * i = table_; i != table_end_; ++i) {
178
3.81M
      Node * n = *i;
179
4.94M
      while (n != 0) {
180
1.12M
  n->data.~Value();
181
1.12M
  n = n->next;
182
1.12M
      }
183
3.81M
    }
184
58.4k
    free (table_);
185
58.4k
    size_ = 0;
186
58.4k
    node_pool_.clear();
187
58.4k
    table_ = 0;
188
58.4k
    table_size_ = 0;
189
58.4k
    prime_index_ = 0;
190
58.4k
  }
acommon::HashTable<acommon::StringMap::Parms>::del()
Line
Count
Source
176
42.1k
  {
177
2.59M
    for (Node * * i = table_; i != table_end_; ++i) {
178
2.54M
      Node * n = *i;
179
3.12M
      while (n != 0) {
180
577k
  n->data.~Value();
181
577k
  n = n->next;
182
577k
      }
183
2.54M
    }
184
42.1k
    free (table_);
185
42.1k
    size_ = 0;
186
42.1k
    node_pool_.clear();
187
42.1k
    table_ = 0;
188
42.1k
    table_size_ = 0;
189
42.1k
    prime_index_ = 0;
190
42.1k
  }
acommon::HashTable<aspeller::CondsLookupParms>::del()
Line
Count
Source
176
766
  {
177
48.4k
    for (Node * * i = table_; i != table_end_; ++i) {
178
47.6k
      Node * n = *i;
179
63.8k
      while (n != 0) {
180
16.1k
  n->data.~Value();
181
16.1k
  n = n->next;
182
16.1k
      }
183
47.6k
    }
184
766
    free (table_);
185
766
    size_ = 0;
186
766
    node_pool_.clear();
187
766
    table_ = 0;
188
766
    table_size_ = 0;
189
766
    prime_index_ = 0;
190
766
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
44
  {
177
3.86k
    for (Node * * i = table_; i != table_end_; ++i) {
178
3.82k
      Node * n = *i;
179
5.28k
      while (n != 0) {
180
1.46k
  n->data.~Value();
181
1.46k
  n = n->next;
182
1.46k
      }
183
3.82k
    }
184
44
    free (table_);
185
44
    size_ = 0;
186
44
    node_pool_.clear();
187
44
    table_ = 0;
188
44
    table_size_ = 0;
189
44
    prime_index_ = 0;
190
44
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::del()
Line
Count
Source
176
10.9k
  {
177
985k
    for (Node * * i = table_; i != table_end_; ++i) {
178
974k
      Node * n = *i;
179
1.50M
      while (n != 0) {
180
529k
  n->data.~Value();
181
529k
  n = n->next;
182
529k
      }
183
974k
    }
184
10.9k
    free (table_);
185
10.9k
    size_ = 0;
186
10.9k
    node_pool_.clear();
187
10.9k
    table_ = 0;
188
10.9k
    table_size_ = 0;
189
10.9k
    prime_index_ = 0;
190
10.9k
  }
acommon::HashTable<acommon::HashMapParms<char const*, acommon::Vector<char const*>, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
2.28k
  {
177
123k
    for (Node * * i = table_; i != table_end_; ++i) {
178
120k
      Node * n = *i;
179
120k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
120k
    }
184
2.28k
    free (table_);
185
2.28k
    size_ = 0;
186
2.28k
    node_pool_.clear();
187
2.28k
    table_ = 0;
188
2.28k
    table_size_ = 0;
189
2.28k
    prime_index_ = 0;
190
2.28k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del()
Line
Count
Source
176
2.28k
  {
177
123k
    for (Node * * i = table_; i != table_end_; ++i) {
178
120k
      Node * n = *i;
179
120k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
120k
    }
184
2.28k
    free (table_);
185
2.28k
    size_ = 0;
186
2.28k
    node_pool_.clear();
187
2.28k
    table_ = 0;
188
2.28k
    table_size_ = 0;
189
2.28k
    prime_index_ = 0;
190
2.28k
  }
191
192
  template <class P>
193
  void HashTable<P>::resize_i(PrimeIndex new_prime_index) 
194
7.27k
  {
195
7.27k
    Node * * old_table = table_;
196
7.27k
    Node * * old_end = table_end_;
197
7.27k
    Size old_size = table_size_;
198
7.27k
    create_table(new_prime_index);
199
479k
    for (Node * * i = old_table; i != old_end; ++i) {
200
472k
      Node * n = *i;
201
945k
      while (n != 0) {
202
472k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
472k
  Node * tmp = n;
204
472k
  n = n->next;
205
472k
  tmp->next = *put_me_here;
206
472k
  *put_me_here = tmp;
207
472k
      }
208
472k
    }
209
7.27k
    free(old_table);
210
7.27k
    node_pool_.add_block(table_size_ - old_size);
211
7.27k
  }
acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int)
Line
Count
Source
194
408
  {
195
408
    Node * * old_table = table_;
196
408
    Node * * old_end = table_end_;
197
408
    Size old_size = table_size_;
198
408
    create_table(new_prime_index);
199
24.2k
    for (Node * * i = old_table; i != old_end; ++i) {
200
23.8k
      Node * n = *i;
201
47.6k
      while (n != 0) {
202
23.8k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
23.8k
  Node * tmp = n;
204
23.8k
  n = n->next;
205
23.8k
  tmp->next = *put_me_here;
206
23.8k
  *put_me_here = tmp;
207
23.8k
      }
208
23.8k
    }
209
408
    free(old_table);
210
408
    node_pool_.add_block(table_size_ - old_size);
211
408
  }
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int)
Line
Count
Source
194
63
  {
195
63
    Node * * old_table = table_;
196
63
    Node * * old_end = table_end_;
197
63
    Size old_size = table_size_;
198
63
    create_table(new_prime_index);
199
7.26k
    for (Node * * i = old_table; i != old_end; ++i) {
200
7.20k
      Node * n = *i;
201
14.4k
      while (n != 0) {
202
7.20k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
7.20k
  Node * tmp = n;
204
7.20k
  n = n->next;
205
7.20k
  tmp->next = *put_me_here;
206
7.20k
  *put_me_here = tmp;
207
7.20k
      }
208
7.20k
    }
209
63
    free(old_table);
210
63
    node_pool_.add_block(table_size_ - old_size);
211
63
  }
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
5
  {
195
5
    Node * * old_table = table_;
196
5
    Node * * old_end = table_end_;
197
5
    Size old_size = table_size_;
198
5
    create_table(new_prime_index);
199
1.50k
    for (Node * * i = old_table; i != old_end; ++i) {
200
1.50k
      Node * n = *i;
201
3.00k
      while (n != 0) {
202
1.50k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
1.50k
  Node * tmp = n;
204
1.50k
  n = n->next;
205
1.50k
  tmp->next = *put_me_here;
206
1.50k
  *put_me_here = tmp;
207
1.50k
      }
208
1.50k
    }
209
5
    free(old_table);
210
5
    node_pool_.add_block(table_size_ - old_size);
211
5
  }
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.79k
  {
195
6.79k
    Node * * old_table = table_;
196
6.79k
    Node * * old_end = table_end_;
197
6.79k
    Size old_size = table_size_;
198
6.79k
    create_table(new_prime_index);
199
446k
    for (Node * * i = old_table; i != old_end; ++i) {
200
440k
      Node * n = *i;
201
880k
      while (n != 0) {
202
440k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
440k
  Node * tmp = n;
204
440k
  n = n->next;
205
440k
  tmp->next = *put_me_here;
206
440k
  *put_me_here = tmp;
207
440k
      }
208
440k
    }
209
6.79k
    free(old_table);
210
6.79k
    node_pool_.add_block(table_size_ - old_size);
211
6.79k
  }
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
13.3k
  {
216
13.3k
    init(other.prime_index_);
217
13.3k
    size_  = other.size_;
218
13.3k
    parms_ = other.parms_;
219
1.02M
    for (unsigned int i = 0; i != other.table_size_; ++i) {
220
1.56M
      for (Node * j = other.table_[i]; j != 0; j = j->next) {
221
555k
  Node * n = node_pool_.new_node();
222
555k
  new 
223
555k
    (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) 
224
555k
    Value(j->data);
225
555k
  n->next = table_[i];
226
555k
  table_[i] = n;
227
555k
      }
228
1.01M
    }
229
13.3k
  }
230
231
}
232
233
234
#endif