Coverage Report

Created: 2025-08-28 06:20

/src/aspell/common/hash-t.hpp
Line
Count
Source (jump to first uncovered line)
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
27.3k
  {
64
27.3k
    PrimeIndex i = prime_index_;
65
27.3k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
27.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
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
20.9k
  {
64
20.9k
    PrimeIndex i = prime_index_;
65
20.9k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
20.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
3.14k
  {
64
3.14k
    PrimeIndex i = prime_index_;
65
3.14k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.14k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::next_largest(unsigned int)
Line
Count
Source
63
3.14k
  {
64
3.14k
    PrimeIndex i = prime_index_;
65
3.14k
    while (assert(primes[i] != static_cast<PrimeIndex>(-1)), primes[i] < s) ++i;
66
0
    return i;
67
3.14k
  }
68
69
  template <class P>
70
114k
  void HashTable<P>::create_table(PrimeIndex i) {
71
114k
    prime_index_ = i;
72
114k
    table_size_ = primes[prime_index_];
73
114k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
114k
    table_end_ = table_ + table_size_;
75
114k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
114k
  }
acommon::HashTable<acommon::StringMap::Parms>::create_table(unsigned int)
Line
Count
Source
70
67.8k
  void HashTable<P>::create_table(PrimeIndex i) {
71
67.8k
    prime_index_ = i;
72
67.8k
    table_size_ = primes[prime_index_];
73
67.8k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
67.8k
    table_end_ = table_ + table_size_;
75
67.8k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
67.8k
  }
acommon::HashTable<aspeller::CondsLookupParms>::create_table(unsigned int)
Line
Count
Source
70
1.17k
  void HashTable<P>::create_table(PrimeIndex i) {
71
1.17k
    prime_index_ = i;
72
1.17k
    table_size_ = primes[prime_index_];
73
1.17k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
1.17k
    table_end_ = table_ + table_size_;
75
1.17k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
1.17k
  }
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
126
  void HashTable<P>::create_table(PrimeIndex i) {
71
126
    prime_index_ = i;
72
126
    table_size_ = primes[prime_index_];
73
126
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
126
    table_end_ = table_ + table_size_;
75
126
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
126
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::create_table(unsigned int)
Line
Count
Source
70
39.0k
  void HashTable<P>::create_table(PrimeIndex i) {
71
39.0k
    prime_index_ = i;
72
39.0k
    table_size_ = primes[prime_index_];
73
39.0k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
39.0k
    table_end_ = table_ + table_size_;
75
39.0k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
39.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.14k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.14k
    prime_index_ = i;
72
3.14k
    table_size_ = primes[prime_index_];
73
3.14k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.14k
    table_end_ = table_ + table_size_;
75
3.14k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.14k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::create_table(unsigned int)
Line
Count
Source
70
3.14k
  void HashTable<P>::create_table(PrimeIndex i) {
71
3.14k
    prime_index_ = i;
72
3.14k
    table_size_ = primes[prime_index_];
73
3.14k
    table_ = reinterpret_cast<Node * *>(calloc(table_size_+1,sizeof(Node *)));
74
3.14k
    table_end_ = table_ + table_size_;
75
3.14k
    *table_end_ = reinterpret_cast<Node *>(table_end_);
76
3.14k
  }
77
78
  template <class P>
79
  void HashTable<P>::init(PrimeIndex i)
80
95.6k
  {
81
95.6k
    size_ = 0;
82
95.6k
    create_table(i);
83
95.6k
    node_pool_.add_block(primes[i]);
84
95.6k
  }
acommon::HashTable<acommon::StringMap::Parms>::init(unsigned int)
Line
Count
Source
80
67.2k
  {
81
67.2k
    size_ = 0;
82
67.2k
    create_table(i);
83
67.2k
    node_pool_.add_block(primes[i]);
84
67.2k
  }
acommon::HashTable<aspeller::CondsLookupParms>::init(unsigned int)
Line
Count
Source
80
1.06k
  {
81
1.06k
    size_ = 0;
82
1.06k
    create_table(i);
83
1.06k
    node_pool_.add_block(primes[i]);
84
1.06k
  }
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
20.9k
  {
81
20.9k
    size_ = 0;
82
20.9k
    create_table(i);
83
20.9k
    node_pool_.add_block(primes[i]);
84
20.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
3.14k
  {
81
3.14k
    size_ = 0;
82
3.14k
    create_table(i);
83
3.14k
    node_pool_.add_block(primes[i]);
84
3.14k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::init(unsigned int)
Line
Count
Source
80
3.14k
  {
81
3.14k
    size_ = 0;
82
3.14k
    create_table(i);
83
3.14k
    node_pool_.add_block(primes[i]);
84
3.14k
  }
85
86
  template <class P>
87
  std::pair<typename HashTable<P>::iterator,bool> HashTable<P>::insert(const Value & to_insert)
88
2.27M
  {
89
2.27M
    bool have;
90
2.27M
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
2.27M
    if (have && !parms_.is_multi) 
92
837k
      return std::pair<iterator,bool>(put_me_here,false);
93
1.43M
    Node * new_node = node_pool_.new_node();
94
1.43M
    if (new_node == 0) {
95
18.8k
      resize_i(prime_index_+1);
96
18.8k
      return insert(to_insert);
97
18.8k
    }
98
1.41M
    new 
99
1.41M
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
1.41M
      Value(to_insert);
101
1.41M
    new_node->next = *put_me_here.n;
102
1.41M
    *put_me_here.n = new_node;
103
1.41M
    ++size_;
104
1.41M
    return std::pair<iterator,bool>(put_me_here,true);
105
1.43M
  }
acommon::HashTable<acommon::StringMap::Parms>::insert(acommon::StringPair const&)
Line
Count
Source
88
58.5k
  {
89
58.5k
    bool have;
90
58.5k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
58.5k
    if (have && !parms_.is_multi) 
92
15.3k
      return std::pair<iterator,bool>(put_me_here,false);
93
43.1k
    Node * new_node = node_pool_.new_node();
94
43.1k
    if (new_node == 0) {
95
547
      resize_i(prime_index_+1);
96
547
      return insert(to_insert);
97
547
    }
98
42.6k
    new 
99
42.6k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
42.6k
      Value(to_insert);
101
42.6k
    new_node->next = *put_me_here.n;
102
42.6k
    *put_me_here.n = new_node;
103
42.6k
    ++size_;
104
42.6k
    return std::pair<iterator,bool>(put_me_here,true);
105
43.1k
  }
acommon::HashTable<aspeller::CondsLookupParms>::insert(aspeller::Conds const* const&)
Line
Count
Source
88
25.5k
  {
89
25.5k
    bool have;
90
25.5k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
25.5k
    if (have && !parms_.is_multi) 
92
0
      return std::pair<iterator,bool>(put_me_here,false);
93
25.5k
    Node * new_node = node_pool_.new_node();
94
25.5k
    if (new_node == 0) {
95
117
      resize_i(prime_index_+1);
96
117
      return insert(to_insert);
97
117
    }
98
25.3k
    new 
99
25.3k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
25.3k
      Value(to_insert);
101
25.3k
    new_node->next = *put_me_here.n;
102
25.3k
    *put_me_here.n = new_node;
103
25.3k
    ++size_;
104
25.3k
    return std::pair<iterator,bool>(put_me_here,true);
105
25.5k
  }
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
166k
  {
89
166k
    bool have;
90
166k
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
166k
    if (have && !parms_.is_multi) 
92
152k
      return std::pair<iterator,bool>(put_me_here,false);
93
13.6k
    Node * new_node = node_pool_.new_node();
94
13.6k
    if (new_node == 0) {
95
86
      resize_i(prime_index_+1);
96
86
      return insert(to_insert);
97
86
    }
98
13.5k
    new 
99
13.5k
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
13.5k
      Value(to_insert);
101
13.5k
    new_node->next = *put_me_here.n;
102
13.5k
    *put_me_here.n = new_node;
103
13.5k
    ++size_;
104
13.5k
    return std::pair<iterator,bool>(put_me_here,true);
105
13.6k
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::insert(char const* const&)
Line
Count
Source
88
2.02M
  {
89
2.02M
    bool have;
90
2.02M
    iterator put_me_here = find_i(parms_.key(to_insert), have);
91
2.02M
    if (have && !parms_.is_multi) 
92
668k
      return std::pair<iterator,bool>(put_me_here,false);
93
1.35M
    Node * new_node = node_pool_.new_node();
94
1.35M
    if (new_node == 0) {
95
18.0k
      resize_i(prime_index_+1);
96
18.0k
      return insert(to_insert);
97
18.0k
    }
98
1.33M
    new 
99
1.33M
      (const_cast<void *>(reinterpret_cast<const void *>(&new_node->data))) 
100
1.33M
      Value(to_insert);
101
1.33M
    new_node->next = *put_me_here.n;
102
1.33M
    *put_me_here.n = new_node;
103
1.33M
    ++size_;
104
1.33M
    return std::pair<iterator,bool>(put_me_here,true);
105
1.35M
  }
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
450
  {
120
450
    Size num_erased = 0;
121
450
    bool irrelevant;
122
450
    Node * * first = find_i(k,irrelevant).n;
123
450
    Node * n = *first;
124
542
    while (n != 0 && parms_.equal(parms_.key(n->data), k)) {
125
92
      Node * tmp = n;
126
92
      n->data.~Value();
127
92
      n = n->next;
128
92
      node_pool_.remove_node(tmp);
129
92
      ++num_erased;
130
92
    }
131
450
    *first = n;
132
450
    size_ -= num_erased;
133
450
    return num_erased;
134
450
  }
135
  
136
  template <class P>
137
  typename HashTable<P>::iterator HashTable<P>::find_i(const Key & to_find, bool & have)
138
28.4M
  {
139
28.4M
    Size pos = parms_.hash(to_find) % table_size_;
140
28.4M
    Node * * n = table_ + pos;
141
28.4M
    have = false;
142
31.1M
    while (true) {
143
31.1M
      if (*n == 0) {
144
26.6M
  break;
145
26.6M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
1.89M
  have = true;
147
1.89M
  break;
148
1.89M
      }
149
2.68M
      n = &(*n)->next;
150
2.68M
    }
151
28.4M
    return iterator(table_ + pos, n);
152
28.4M
  }
acommon::HashTable<acommon::StringMap::Parms>::find_i(char const* const&, bool&)
Line
Count
Source
138
351k
  {
139
351k
    Size pos = parms_.hash(to_find) % table_size_;
140
351k
    Node * * n = table_ + pos;
141
351k
    have = false;
142
479k
    while (true) {
143
479k
      if (*n == 0) {
144
324k
  break;
145
324k
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
26.9k
  have = true;
147
26.9k
  break;
148
26.9k
      }
149
127k
      n = &(*n)->next;
150
127k
    }
151
351k
    return iterator(table_ + pos, n);
152
351k
  }
acommon::HashTable<aspeller::CondsLookupParms>::find_i(char const* const&, bool&)
Line
Count
Source
138
1.08M
  {
139
1.08M
    Size pos = parms_.hash(to_find) % table_size_;
140
1.08M
    Node * * n = table_ + pos;
141
1.08M
    have = false;
142
1.68M
    while (true) {
143
1.68M
      if (*n == 0) {
144
50.8k
  break;
145
1.63M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
1.03M
  have = true;
147
1.03M
  break;
148
1.03M
      }
149
600k
      n = &(*n)->next;
150
600k
    }
151
1.08M
    return iterator(table_ + pos, n);
152
1.08M
  }
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.24M
  {
139
2.24M
    Size pos = parms_.hash(to_find) % table_size_;
140
2.24M
    Node * * n = table_ + pos;
141
2.24M
    have = false;
142
3.38M
    while (true) {
143
3.38M
      if (*n == 0) {
144
2.07M
  break;
145
2.07M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
166k
  have = true;
147
166k
  break;
148
166k
      }
149
1.14M
      n = &(*n)->next;
150
1.14M
    }
151
2.24M
    return iterator(table_ + pos, n);
152
2.24M
  }
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
2.02M
  {
139
2.02M
    Size pos = parms_.hash(to_find) % table_size_;
140
2.02M
    Node * * n = table_ + pos;
141
2.02M
    have = false;
142
2.83M
    while (true) {
143
2.83M
      if (*n == 0) {
144
1.35M
  break;
145
1.48M
      } else if (parms_.equal(parms_.key((*n)->data),to_find)) {
146
668k
  have = true;
147
668k
  break;
148
668k
      }
149
813k
      n = &(*n)->next;
150
813k
    }
151
2.02M
    return iterator(table_ + pos, n);
152
2.02M
  }
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
22.7M
  {
139
22.7M
    Size pos = parms_.hash(to_find) % table_size_;
140
22.7M
    Node * * n = table_ + pos;
141
22.7M
    have = false;
142
22.7M
    while (true) {
143
22.7M
      if (*n == 0) {
144
22.7M
  break;
145
22.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
22.7M
    return iterator(table_ + pos, n);
152
22.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
22.7M
  {
158
22.7M
    c = 0;
159
22.7M
    bool have;
160
22.7M
    iterator first = find_i(to_find,have);
161
22.7M
    if (!have)
162
22.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
22.7M
  }
173
174
  template <class P>
175
  void HashTable<P>::del() 
176
95.4k
  {
177
6.85M
    for (Node * * i = table_; i != table_end_; ++i) {
178
6.76M
      Node * n = *i;
179
9.07M
      while (n != 0) {
180
2.31M
  n->data.~Value();
181
2.31M
  n = n->next;
182
2.31M
      }
183
6.76M
    }
184
95.4k
    free (table_);
185
95.4k
    size_ = 0;
186
95.4k
    node_pool_.clear();
187
95.4k
    table_ = 0;
188
95.4k
    table_size_ = 0;
189
95.4k
    prime_index_ = 0;
190
95.4k
  }
acommon::HashTable<acommon::StringMap::Parms>::del()
Line
Count
Source
176
67.0k
  {
177
4.11M
    for (Node * * i = table_; i != table_end_; ++i) {
178
4.04M
      Node * n = *i;
179
4.98M
      while (n != 0) {
180
935k
  n->data.~Value();
181
935k
  n = n->next;
182
935k
      }
183
4.04M
    }
184
67.0k
    free (table_);
185
67.0k
    size_ = 0;
186
67.0k
    node_pool_.clear();
187
67.0k
    table_ = 0;
188
67.0k
    table_size_ = 0;
189
67.0k
    prime_index_ = 0;
190
67.0k
  }
acommon::HashTable<aspeller::CondsLookupParms>::del()
Line
Count
Source
176
1.06k
  {
177
70.4k
    for (Node * * i = table_; i != table_end_; ++i) {
178
69.3k
      Node * n = *i;
179
94.7k
      while (n != 0) {
180
25.3k
  n->data.~Value();
181
25.3k
  n = n->next;
182
25.3k
      }
183
69.3k
    }
184
1.06k
    free (table_);
185
1.06k
    size_ = 0;
186
1.06k
    node_pool_.clear();
187
1.06k
    table_ = 0;
188
1.06k
    table_size_ = 0;
189
1.06k
    prime_index_ = 0;
190
1.06k
  }
acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, std::__1::equal_to<char const*>, false> >::del()
Line
Count
Source
176
40
  {
177
20.6k
    for (Node * * i = table_; i != table_end_; ++i) {
178
20.6k
      Node * n = *i;
179
34.2k
      while (n != 0) {
180
13.5k
  n->data.~Value();
181
13.5k
  n = n->next;
182
13.5k
      }
183
20.6k
    }
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
20.9k
  {
177
2.31M
    for (Node * * i = table_; i != table_end_; ++i) {
178
2.29M
      Node * n = *i;
179
3.62M
      while (n != 0) {
180
1.33M
  n->data.~Value();
181
1.33M
  n = n->next;
182
1.33M
      }
183
2.29M
    }
184
20.9k
    free (table_);
185
20.9k
    size_ = 0;
186
20.9k
    node_pool_.clear();
187
20.9k
    table_ = 0;
188
20.9k
    table_size_ = 0;
189
20.9k
    prime_index_ = 0;
190
20.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
3.14k
  {
177
169k
    for (Node * * i = table_; i != table_end_; ++i) {
178
166k
      Node * n = *i;
179
166k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
166k
    }
184
3.14k
    free (table_);
185
3.14k
    size_ = 0;
186
3.14k
    node_pool_.clear();
187
3.14k
    table_ = 0;
188
3.14k
    table_size_ = 0;
189
3.14k
    prime_index_ = 0;
190
3.14k
  }
writable.cpp:acommon::HashTable<acommon::HashSetParms<char const*, (anonymous namespace)::Hash, (anonymous namespace)::Equal, true> >::del()
Line
Count
Source
176
3.14k
  {
177
169k
    for (Node * * i = table_; i != table_end_; ++i) {
178
166k
      Node * n = *i;
179
166k
      while (n != 0) {
180
0
  n->data.~Value();
181
0
  n = n->next;
182
0
      }
183
166k
    }
184
3.14k
    free (table_);
185
3.14k
    size_ = 0;
186
3.14k
    node_pool_.clear();
187
3.14k
    table_ = 0;
188
3.14k
    table_size_ = 0;
189
3.14k
    prime_index_ = 0;
190
3.14k
  }
191
192
  template <class P>
193
  void HashTable<P>::resize_i(PrimeIndex new_prime_index) 
194
18.8k
  {
195
18.8k
    Node * * old_table = table_;
196
18.8k
    Node * * old_end = table_end_;
197
18.8k
    Size old_size = table_size_;
198
18.8k
    create_table(new_prime_index);
199
1.37M
    for (Node * * i = old_table; i != old_end; ++i) {
200
1.36M
      Node * n = *i;
201
2.72M
      while (n != 0) {
202
1.36M
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
1.36M
  Node * tmp = n;
204
1.36M
  n = n->next;
205
1.36M
  tmp->next = *put_me_here;
206
1.36M
  *put_me_here = tmp;
207
1.36M
      }
208
1.36M
    }
209
18.8k
    free(old_table);
210
18.8k
    node_pool_.add_block(table_size_ - old_size);
211
18.8k
  }
acommon::HashTable<acommon::StringMap::Parms>::resize_i(unsigned int)
Line
Count
Source
194
547
  {
195
547
    Node * * old_table = table_;
196
547
    Node * * old_end = table_end_;
197
547
    Size old_size = table_size_;
198
547
    create_table(new_prime_index);
199
32.6k
    for (Node * * i = old_table; i != old_end; ++i) {
200
32.1k
      Node * n = *i;
201
64.2k
      while (n != 0) {
202
32.1k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
32.1k
  Node * tmp = n;
204
32.1k
  n = n->next;
205
32.1k
  tmp->next = *put_me_here;
206
32.1k
  *put_me_here = tmp;
207
32.1k
      }
208
32.1k
    }
209
547
    free(old_table);
210
547
    node_pool_.add_block(table_size_ - old_size);
211
547
  }
acommon::HashTable<aspeller::CondsLookupParms>::resize_i(unsigned int)
Line
Count
Source
194
117
  {
195
117
    Node * * old_table = table_;
196
117
    Node * * old_end = table_end_;
197
117
    Size old_size = table_size_;
198
117
    create_table(new_prime_index);
199
13.4k
    for (Node * * i = old_table; i != old_end; ++i) {
200
13.3k
      Node * n = *i;
201
26.7k
      while (n != 0) {
202
13.3k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
13.3k
  Node * tmp = n;
204
13.3k
  n = n->next;
205
13.3k
  tmp->next = *put_me_here;
206
13.3k
  *put_me_here = tmp;
207
13.3k
      }
208
13.3k
    }
209
117
    free(old_table);
210
117
    node_pool_.add_block(table_size_ - old_size);
211
117
  }
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
86
  {
195
86
    Node * * old_table = table_;
196
86
    Node * * old_end = table_end_;
197
86
    Size old_size = table_size_;
198
86
    create_table(new_prime_index);
199
18.9k
    for (Node * * i = old_table; i != old_end; ++i) {
200
18.8k
      Node * n = *i;
201
37.6k
      while (n != 0) {
202
18.8k
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
18.8k
  Node * tmp = n;
204
18.8k
  n = n->next;
205
18.8k
  tmp->next = *put_me_here;
206
18.8k
  *put_me_here = tmp;
207
18.8k
      }
208
18.8k
    }
209
86
    free(old_table);
210
86
    node_pool_.add_block(table_size_ - old_size);
211
86
  }
suggest.cpp:acommon::HashTable<acommon::HashSetParms<char const*, acommon::hash<char const*>, (anonymous namespace)::StrEquals, false> >::resize_i(unsigned int)
Line
Count
Source
194
18.0k
  {
195
18.0k
    Node * * old_table = table_;
196
18.0k
    Node * * old_end = table_end_;
197
18.0k
    Size old_size = table_size_;
198
18.0k
    create_table(new_prime_index);
199
1.31M
    for (Node * * i = old_table; i != old_end; ++i) {
200
1.29M
      Node * n = *i;
201
2.59M
      while (n != 0) {
202
1.29M
  Node * * put_me_here = table_ + (parms_.hash(parms_.key(n->data)) % table_size_);
203
1.29M
  Node * tmp = n;
204
1.29M
  n = n->next;
205
1.29M
  tmp->next = *put_me_here;
206
1.29M
  *put_me_here = tmp;
207
1.29M
      }
208
1.29M
    }
209
18.0k
    free(old_table);
210
18.0k
    node_pool_.add_block(table_size_ - old_size);
211
18.0k
  }
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
21.5k
  {
216
21.5k
    init(other.prime_index_);
217
21.5k
    size_  = other.size_;
218
21.5k
    parms_ = other.parms_;
219
1.63M
    for (unsigned int i = 0; i != other.table_size_; ++i) {
220
2.51M
      for (Node * j = other.table_[i]; j != 0; j = j->next) {
221
905k
  Node * n = node_pool_.new_node();
222
905k
  new 
223
905k
    (const_cast<void *>(reinterpret_cast<const void *>(&n->data))) 
224
905k
    Value(j->data);
225
905k
  n->next = table_[i];
226
905k
  table_[i] = n;
227
905k
      }
228
1.61M
    }
229
21.5k
  }
230
231
}
232
233
234
#endif