2929#include " firebird.h"
3030
3131#include < stdarg.h>
32- #include < algorithm>
3332
3433#include " ../jrd/MetaName.h"
3534#include " ../common/classes/MetaString.h"
@@ -43,7 +42,7 @@ int MetaName::compare(const char* s, FB_SIZE_T len) const
4342 if (s)
4443 {
4544 adjustLength (s, len);
46- const FB_SIZE_T x = std::min ( length (), len) ;
45+ FB_SIZE_T x = length () < len ? length () : len ;
4746 int rc = memcmp (c_str (), s, x);
4847 if (rc)
4948 {
@@ -56,11 +55,11 @@ int MetaName::compare(const char* s, FB_SIZE_T len) const
5655 return length () - len;
5756}
5857
59- void MetaName::adjustLength (const char * const s, FB_SIZE_T& len) noexcept
58+ void MetaName::adjustLength (const char * const s, FB_SIZE_T& len)
6059{
61- fb_assert (s);
6260 if (len > MAX_SQL_IDENTIFIER_LEN)
6361 {
62+ fb_assert (s);
6463#ifdef DEV_BUILD
6564 for (FB_SIZE_T i = MAX_SQL_IDENTIFIER_LEN; i < len; ++i)
6665 fb_assert (s[i] == ' \0 ' || s[i] == ' ' );
@@ -82,7 +81,7 @@ void MetaName::printf(const char* format, ...)
8281 char data[MAX_SQL_IDENTIFIER_LEN + 1 ];
8382 va_list params;
8483 va_start (params, format);
85- int len = vsnprintf (data, MAX_SQL_IDENTIFIER_LEN, format, params);
84+ int len = VSNPRINTF (data, MAX_SQL_IDENTIFIER_LEN, format, params);
8685 va_end (params);
8786
8887 if (len < 0 || FB_SIZE_T (len) > MAX_SQL_IDENTIFIER_LEN)
@@ -106,7 +105,7 @@ FB_SIZE_T MetaName::copyTo(char* to, FB_SIZE_T toSize) const
106105 return toSize;
107106}
108107
109- MetaName::operator Firebird::MetaString () const noexcept
108+ MetaName::operator Firebird::MetaString () const
110109{
111110 return Firebird::MetaString (c_str (), length ());
112111}
@@ -126,7 +125,7 @@ void MetaName::test()
126125#if defined(DEV_BUILD) || GROW_DEBUG > 0
127126 if (word)
128127 {
129- const Dictionary::Word* checkWord = get (word->c_str (), word->length ());
128+ Dictionary::Word* checkWord = get (word->c_str (), word->length ());
130129 fb_assert (checkWord == word);
131130#ifndef DEV_BUILD
132131 if (word != checkWord)
@@ -136,15 +135,17 @@ void MetaName::test()
136135#endif
137136}
138137
138+ const char * MetaName::EMPTY = " " ;
139+
139140#if GROW_DEBUG > 1
140- static constexpr unsigned int hashSize[] = {1000 , 2000 , 4000 , 6000 , 8000 , 10000 ,
141+ static const unsigned int hashSize[] = {1000 , 2000 , 4000 , 6000 , 8000 , 10000 ,
141142 12000 , 14000 , 16000 , 18000 , 20000 ,
142143 22000 , 24000 , 26000 , 28000 , 30000 ,
143144 32000 , 34000 , 36000 , 38000 , 40000 ,
144145 42000 , 44000 , 46000 , 48000 , 50000 ,
145146 52000 , 54000 , 56000 , 58000 , 60000 };
146147#else
147- static constexpr unsigned int hashSize[] = { 10007 , 100003 , 1000003 };
148+ static const unsigned int hashSize[] = { 10007 , 100003 , 1000003 };
148149#endif
149150
150151Dictionary::Dictionary (MemoryPool& p)
@@ -186,7 +187,7 @@ Dictionary::HashTable::HashTable(MemoryPool& p, unsigned lvl)
186187 table[n].store (nullptr , std::memory_order_relaxed);
187188}
188189
189- unsigned Dictionary::HashTable::getMaxLevel () noexcept
190+ unsigned Dictionary::HashTable::getMaxLevel ()
190191{
191192 return FB_NELEM (hashSize) - 1 ;
192193}
@@ -222,7 +223,7 @@ Dictionary::TableData* Dictionary::HashTable::getEntryByHash(const char* s, FB_S
222223 return &table[h];
223224}
224225
225- bool Dictionary::checkConsistency (const Dictionary::HashTable* oldValue) noexcept
226+ bool Dictionary::checkConsistency (Dictionary::HashTable* oldValue)
226227{
227228 return oldValue->level == nextLevel.load ();
228229}
@@ -290,7 +291,7 @@ Dictionary::Word* Dictionary::get(const char* s, FB_SIZE_T len)
290291 {
291292 segment = FB_NEW_POOL (getPool ()) Segment;
292293 ++segCount;
293- const unsigned lvl = nextLevel.load ();
294+ unsigned lvl = nextLevel.load ();
294295 if (lvl < HashTable::getMaxLevel () &&
295296 segCount * Segment::getWordCapacity () > hashSize[lvl])
296297 {
@@ -365,7 +366,7 @@ void Dictionary::growHash()
365366
366367 // move one level up size of hash table
367368 HashTable* tab = hashTable.load ();
368- const unsigned lvl = ++nextLevel;
369+ unsigned lvl = ++nextLevel;
369370 fb_assert (lvl == tab->level + 1 );
370371 fb_assert (lvl <= HashTable::getMaxLevel ());
371372
@@ -420,7 +421,7 @@ Dictionary::HashTable* Dictionary::waitForMutex(Jrd::Dictionary::Word** checkWor
420421 return t;
421422
422423 // may be we already have that word in new table
423- const FB_SIZE_T len = (*checkWordPtr)->length ();
424+ FB_SIZE_T len = (*checkWordPtr)->length ();
424425 const char * s = (*checkWordPtr)->c_str ();
425426 Word* word = t->getEntryByHash (s, len)->load ();
426427 while (word)
@@ -440,25 +441,25 @@ Dictionary::HashTable* Dictionary::waitForMutex(Jrd::Dictionary::Word** checkWor
440441 return t;
441442}
442443
443- Dictionary::Segment::Segment () noexcept
444+ Dictionary::Segment::Segment ()
444445{
445446 position.store (0 , std::memory_order_relaxed);
446447}
447448
448- constexpr unsigned Dictionary::Segment::getWordCapacity () noexcept
449+ unsigned Dictionary::Segment::getWordCapacity ()
449450{
450- constexpr unsigned AVERAGE_BYTES_LEN = 16 ;
451+ const unsigned AVERAGE_BYTES_LEN = 16 ;
451452 return SEG_BUFFER_SIZE / getWordLength (AVERAGE_BYTES_LEN);
452453}
453454
454- constexpr unsigned Dictionary::Segment::getWordLength (FB_SIZE_T len) noexcept
455+ unsigned Dictionary::Segment::getWordLength (FB_SIZE_T len)
455456{
456457 // calculate length in sizeof(Word*)
457458 len += 2 ;
458- return 1 + (len / sizeof (Word*)) + (( len % sizeof (Word*) ) ? 1 : 0 );
459+ return 1 + (len / sizeof (Word*)) + (len % sizeof (Word*) ? 1 : 0 );
459460}
460461
461- Dictionary::Word* Dictionary::Segment::getSpace (FB_SIZE_T len DIC_STAT_SEGMENT_PAR) noexcept
462+ Dictionary::Word* Dictionary::Segment::getSpace (FB_SIZE_T len DIC_STAT_SEGMENT_PAR)
462463{
463464 len = getWordLength (len);
464465
@@ -469,7 +470,7 @@ Dictionary::Word* Dictionary::Segment::getSpace(FB_SIZE_T len DIC_STAT_SEGMENT_P
469470 for (;;)
470471 {
471472 // calculate and check new position
472- const unsigned newPos = oldPos + len;
473+ unsigned newPos = oldPos + len;
473474 if (newPos >= SEG_BUFFER_SIZE)
474475 break ;
475476
0 commit comments