@@ -76,7 +76,7 @@ namespace Firebird
76
76
}
77
77
};
78
78
79
- const FB_SIZE_T DEFAULT_HASH_SIZE = 97 ; // largest prime number < 100
79
+ inline constexpr FB_SIZE_T DEFAULT_HASH_SIZE = 97 ; // largest prime number < 100
80
80
81
81
template <typename C,
82
82
FB_SIZE_T HASHSIZE = DEFAULT_HASH_SIZE,
@@ -94,14 +94,14 @@ namespace Firebird
94
94
Entry* nextElement;
95
95
96
96
public:
97
- Entry () : previousElement(NULL ) { }
97
+ Entry () noexcept : previousElement( NULL ), nextElement (NULL ) { }
98
98
99
99
virtual ~Entry ()
100
100
{
101
101
unLink ();
102
102
}
103
103
104
- void link (Entry** where)
104
+ void link (Entry** where) noexcept
105
105
{
106
106
unLink ();
107
107
@@ -119,7 +119,7 @@ namespace Firebird
119
119
*previousElement = this ;
120
120
}
121
121
122
- void unLink ()
122
+ void unLink () noexcept
123
123
{
124
124
// if we are linked
125
125
if (previousElement)
@@ -136,12 +136,12 @@ namespace Firebird
136
136
}
137
137
}
138
138
139
- Entry** nextPtr ()
139
+ Entry** nextPtr () noexcept
140
140
{
141
141
return &nextElement;
142
142
}
143
143
144
- Entry* next () const
144
+ Entry* next () const noexcept
145
145
{
146
146
return nextElement;
147
147
}
@@ -156,20 +156,13 @@ namespace Firebird
156
156
virtual C* get () = 0;
157
157
}; // class Entry
158
158
159
- private:
160
- HashTable (const HashTable&); // not implemented
161
-
162
159
public:
163
- explicit HashTable (MemoryPool&)
164
- : duplicates(false )
160
+ explicit HashTable (MemoryPool&) noexcept
165
161
{
166
- clean ();
167
162
}
168
163
169
- HashTable ()
170
- : duplicates(false )
164
+ HashTable () noexcept
171
165
{
172
- clean ();
173
166
}
174
167
175
168
~HashTable ()
@@ -178,6 +171,9 @@ namespace Firebird
178
171
cleanup (NULL );
179
172
}
180
173
174
+ HashTable (const HashTable&) = delete ;
175
+ HashTable& operator = (const HashTable&) = delete ;
176
+
181
177
typedef void CleanupRoutine (C* toClean);
182
178
void cleanup (CleanupRoutine* cleanupRoutine)
183
179
{
@@ -193,14 +189,14 @@ namespace Firebird
193
189
}
194
190
}
195
191
196
- void enableDuplicates ()
192
+ void enableDuplicates () noexcept
197
193
{
198
194
duplicates = true ;
199
195
}
200
196
201
197
private:
202
- Entry* data[HASHSIZE];
203
- bool duplicates;
198
+ Entry* data[HASHSIZE]{} ;
199
+ bool duplicates = false ;
204
200
205
201
Entry** locate (const K& key, FB_SIZE_T h)
206
202
{
@@ -219,7 +215,7 @@ namespace Firebird
219
215
220
216
Entry** locate (const K& key)
221
217
{
222
- FB_SIZE_T hashValue = F::hash (key, HASHSIZE);
218
+ const FB_SIZE_T hashValue = F::hash (key, HASHSIZE);
223
219
fb_assert (hashValue < HASHSIZE);
224
220
return locate (key, hashValue % HASHSIZE);
225
221
}
@@ -254,15 +250,6 @@ namespace Firebird
254
250
return NULL ;
255
251
}
256
252
257
- private:
258
- // disable use of default operator=
259
- HashTable& operator = (const HashTable&);
260
-
261
- void clean ()
262
- {
263
- memset (data, 0 , sizeof data);
264
- }
265
-
266
253
public:
267
254
class iterator
268
255
{
@@ -335,9 +322,9 @@ namespace Firebird
335
322
class InternalHash
336
323
{
337
324
public:
338
- static unsigned int hash (unsigned int length, const UCHAR* value);
325
+ static unsigned int hash (unsigned int length, const UCHAR* value) noexcept ;
339
326
340
- static unsigned int hash (unsigned int length, const UCHAR* value, unsigned int hashSize)
327
+ static unsigned int hash (unsigned int length, const UCHAR* value, unsigned int hashSize) noexcept
341
328
{
342
329
return hash (length, value) % hashSize;
343
330
}
@@ -358,8 +345,8 @@ namespace Firebird
358
345
class WeakHashContext final : public HashContext
359
346
{
360
347
public:
361
- virtual void update (const void * data, FB_SIZE_T length);
362
- virtual void finish (dsc& result);
348
+ void update (const void * data, FB_SIZE_T length) override ;
349
+ void finish (dsc& result) override ;
363
350
364
351
private:
365
352
SINT64 hashNumber = 0 ;
0 commit comments