@@ -76,7 +76,7 @@ namespace Firebird
7676 }
7777 };
7878
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
8080
8181 template <typename C,
8282 FB_SIZE_T HASHSIZE = DEFAULT_HASH_SIZE,
@@ -94,14 +94,14 @@ namespace Firebird
9494 Entry* nextElement;
9595
9696 public:
97- Entry () : previousElement(NULL ) { }
97+ Entry () noexcept : previousElement( NULL ), nextElement (NULL ) { }
9898
9999 virtual ~Entry ()
100100 {
101101 unLink ();
102102 }
103103
104- void link (Entry** where)
104+ void link (Entry** where) noexcept
105105 {
106106 unLink ();
107107
@@ -119,7 +119,7 @@ namespace Firebird
119119 *previousElement = this ;
120120 }
121121
122- void unLink ()
122+ void unLink () noexcept
123123 {
124124 // if we are linked
125125 if (previousElement)
@@ -136,12 +136,12 @@ namespace Firebird
136136 }
137137 }
138138
139- Entry** nextPtr ()
139+ Entry** nextPtr () noexcept
140140 {
141141 return &nextElement;
142142 }
143143
144- Entry* next () const
144+ Entry* next () const noexcept
145145 {
146146 return nextElement;
147147 }
@@ -156,20 +156,13 @@ namespace Firebird
156156 virtual C* get () = 0;
157157 }; // class Entry
158158
159- private:
160- HashTable (const HashTable&); // not implemented
161-
162159 public:
163- explicit HashTable (MemoryPool&)
164- : duplicates(false )
160+ explicit HashTable (MemoryPool&) noexcept
165161 {
166- clean ();
167162 }
168163
169- HashTable ()
170- : duplicates(false )
164+ HashTable () noexcept
171165 {
172- clean ();
173166 }
174167
175168 ~HashTable ()
@@ -178,6 +171,9 @@ namespace Firebird
178171 cleanup (NULL );
179172 }
180173
174+ HashTable (const HashTable&) = delete ;
175+ HashTable& operator = (const HashTable&) = delete ;
176+
181177 typedef void CleanupRoutine (C* toClean);
182178 void cleanup (CleanupRoutine* cleanupRoutine)
183179 {
@@ -193,14 +189,14 @@ namespace Firebird
193189 }
194190 }
195191
196- void enableDuplicates ()
192+ void enableDuplicates () noexcept
197193 {
198194 duplicates = true ;
199195 }
200196
201197 private:
202- Entry* data[HASHSIZE];
203- bool duplicates;
198+ Entry* data[HASHSIZE]{} ;
199+ bool duplicates = false ;
204200
205201 Entry** locate (const K& key, FB_SIZE_T h)
206202 {
@@ -219,7 +215,7 @@ namespace Firebird
219215
220216 Entry** locate (const K& key)
221217 {
222- FB_SIZE_T hashValue = F::hash (key, HASHSIZE);
218+ const FB_SIZE_T hashValue = F::hash (key, HASHSIZE);
223219 fb_assert (hashValue < HASHSIZE);
224220 return locate (key, hashValue % HASHSIZE);
225221 }
@@ -254,15 +250,6 @@ namespace Firebird
254250 return NULL ;
255251 }
256252
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-
266253 public:
267254 class iterator
268255 {
@@ -335,9 +322,9 @@ namespace Firebird
335322 class InternalHash
336323 {
337324 public:
338- static unsigned int hash (unsigned int length, const UCHAR* value);
325+ static unsigned int hash (unsigned int length, const UCHAR* value) noexcept ;
339326
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
341328 {
342329 return hash (length, value) % hashSize;
343330 }
@@ -358,8 +345,8 @@ namespace Firebird
358345 class WeakHashContext final : public HashContext
359346 {
360347 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 ;
363350
364351 private:
365352 SINT64 hashNumber = 0 ;
0 commit comments