29
29
#include " firebird.h"
30
30
31
31
#include < stdarg.h>
32
- #include < algorithm>
33
32
34
33
#include " ../jrd/MetaName.h"
35
34
#include " ../common/classes/MetaString.h"
@@ -43,7 +42,7 @@ int MetaName::compare(const char* s, FB_SIZE_T len) const
43
42
if (s)
44
43
{
45
44
adjustLength (s, len);
46
- const FB_SIZE_T x = std::min ( length (), len) ;
45
+ FB_SIZE_T x = length () < len ? length () : len ;
47
46
int rc = memcmp (c_str (), s, x);
48
47
if (rc)
49
48
{
@@ -56,11 +55,11 @@ int MetaName::compare(const char* s, FB_SIZE_T len) const
56
55
return length () - len;
57
56
}
58
57
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)
60
59
{
61
- fb_assert (s);
62
60
if (len > MAX_SQL_IDENTIFIER_LEN)
63
61
{
62
+ fb_assert (s);
64
63
#ifdef DEV_BUILD
65
64
for (FB_SIZE_T i = MAX_SQL_IDENTIFIER_LEN; i < len; ++i)
66
65
fb_assert (s[i] == ' \0 ' || s[i] == ' ' );
@@ -82,7 +81,7 @@ void MetaName::printf(const char* format, ...)
82
81
char data[MAX_SQL_IDENTIFIER_LEN + 1 ];
83
82
va_list params;
84
83
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);
86
85
va_end (params);
87
86
88
87
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
106
105
return toSize;
107
106
}
108
107
109
- MetaName::operator Firebird::MetaString () const noexcept
108
+ MetaName::operator Firebird::MetaString () const
110
109
{
111
110
return Firebird::MetaString (c_str (), length ());
112
111
}
@@ -126,7 +125,7 @@ void MetaName::test()
126
125
#if defined(DEV_BUILD) || GROW_DEBUG > 0
127
126
if (word)
128
127
{
129
- const Dictionary::Word* checkWord = get (word->c_str (), word->length ());
128
+ Dictionary::Word* checkWord = get (word->c_str (), word->length ());
130
129
fb_assert (checkWord == word);
131
130
#ifndef DEV_BUILD
132
131
if (word != checkWord)
@@ -136,15 +135,17 @@ void MetaName::test()
136
135
#endif
137
136
}
138
137
138
+ const char * MetaName::EMPTY = " " ;
139
+
139
140
#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 ,
141
142
12000 , 14000 , 16000 , 18000 , 20000 ,
142
143
22000 , 24000 , 26000 , 28000 , 30000 ,
143
144
32000 , 34000 , 36000 , 38000 , 40000 ,
144
145
42000 , 44000 , 46000 , 48000 , 50000 ,
145
146
52000 , 54000 , 56000 , 58000 , 60000 };
146
147
#else
147
- static constexpr unsigned int hashSize[] = { 10007 , 100003 , 1000003 };
148
+ static const unsigned int hashSize[] = { 10007 , 100003 , 1000003 };
148
149
#endif
149
150
150
151
Dictionary::Dictionary (MemoryPool& p)
@@ -186,7 +187,7 @@ Dictionary::HashTable::HashTable(MemoryPool& p, unsigned lvl)
186
187
table[n].store (nullptr , std::memory_order_relaxed);
187
188
}
188
189
189
- unsigned Dictionary::HashTable::getMaxLevel () noexcept
190
+ unsigned Dictionary::HashTable::getMaxLevel ()
190
191
{
191
192
return FB_NELEM (hashSize) - 1 ;
192
193
}
@@ -222,7 +223,7 @@ Dictionary::TableData* Dictionary::HashTable::getEntryByHash(const char* s, FB_S
222
223
return &table[h];
223
224
}
224
225
225
- bool Dictionary::checkConsistency (const Dictionary::HashTable* oldValue) noexcept
226
+ bool Dictionary::checkConsistency (Dictionary::HashTable* oldValue)
226
227
{
227
228
return oldValue->level == nextLevel.load ();
228
229
}
@@ -290,7 +291,7 @@ Dictionary::Word* Dictionary::get(const char* s, FB_SIZE_T len)
290
291
{
291
292
segment = FB_NEW_POOL (getPool ()) Segment;
292
293
++segCount;
293
- const unsigned lvl = nextLevel.load ();
294
+ unsigned lvl = nextLevel.load ();
294
295
if (lvl < HashTable::getMaxLevel () &&
295
296
segCount * Segment::getWordCapacity () > hashSize[lvl])
296
297
{
@@ -365,7 +366,7 @@ void Dictionary::growHash()
365
366
366
367
// move one level up size of hash table
367
368
HashTable* tab = hashTable.load ();
368
- const unsigned lvl = ++nextLevel;
369
+ unsigned lvl = ++nextLevel;
369
370
fb_assert (lvl == tab->level + 1 );
370
371
fb_assert (lvl <= HashTable::getMaxLevel ());
371
372
@@ -420,7 +421,7 @@ Dictionary::HashTable* Dictionary::waitForMutex(Jrd::Dictionary::Word** checkWor
420
421
return t;
421
422
422
423
// 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 ();
424
425
const char * s = (*checkWordPtr)->c_str ();
425
426
Word* word = t->getEntryByHash (s, len)->load ();
426
427
while (word)
@@ -440,25 +441,25 @@ Dictionary::HashTable* Dictionary::waitForMutex(Jrd::Dictionary::Word** checkWor
440
441
return t;
441
442
}
442
443
443
- Dictionary::Segment::Segment () noexcept
444
+ Dictionary::Segment::Segment ()
444
445
{
445
446
position.store (0 , std::memory_order_relaxed);
446
447
}
447
448
448
- constexpr unsigned Dictionary::Segment::getWordCapacity () noexcept
449
+ unsigned Dictionary::Segment::getWordCapacity ()
449
450
{
450
- constexpr unsigned AVERAGE_BYTES_LEN = 16 ;
451
+ const unsigned AVERAGE_BYTES_LEN = 16 ;
451
452
return SEG_BUFFER_SIZE / getWordLength (AVERAGE_BYTES_LEN);
452
453
}
453
454
454
- constexpr unsigned Dictionary::Segment::getWordLength (FB_SIZE_T len) noexcept
455
+ unsigned Dictionary::Segment::getWordLength (FB_SIZE_T len)
455
456
{
456
457
// calculate length in sizeof(Word*)
457
458
len += 2 ;
458
- return 1 + (len / sizeof (Word*)) + (( len % sizeof (Word*) ) ? 1 : 0 );
459
+ return 1 + (len / sizeof (Word*)) + (len % sizeof (Word*) ? 1 : 0 );
459
460
}
460
461
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)
462
463
{
463
464
len = getWordLength (len);
464
465
@@ -469,7 +470,7 @@ Dictionary::Word* Dictionary::Segment::getSpace(FB_SIZE_T len DIC_STAT_SEGMENT_P
469
470
for (;;)
470
471
{
471
472
// calculate and check new position
472
- const unsigned newPos = oldPos + len;
473
+ unsigned newPos = oldPos + len;
473
474
if (newPos >= SEG_BUFFER_SIZE)
474
475
break ;
475
476
0 commit comments