Skip to content

Commit 95b77a4

Browse files
committed
Revert "noexcept + const in MetaName"
This reverts commit d2caf98.
1 parent d2caf98 commit 95b77a4

File tree

2 files changed

+47
-46
lines changed

2 files changed

+47
-46
lines changed

src/jrd/MetaName.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
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

150151
Dictionary::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

src/jrd/MetaName.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ class Dictionary : public Firebird::PermanentStorage
7373
char text[1];
7474

7575
public:
76-
const char* c_str() const noexcept
76+
const char* c_str() const
7777
{
7878
return text;
7979
}
8080

81-
FB_SIZE_T length() const noexcept
81+
FB_SIZE_T length() const
8282
{
8383
return textLen;
8484
}
@@ -102,31 +102,31 @@ class Dictionary : public Firebird::PermanentStorage
102102
public:
103103
HashTable(MemoryPool& p, unsigned lvl);
104104
Dictionary::TableData* getEntryByHash(const char* s, FB_SIZE_T len);
105-
static unsigned getMaxLevel() noexcept;
105+
static unsigned getMaxLevel();
106106

107107
const unsigned level;
108108
TableData* table;
109109
};
110110
std::atomic<HashTable*> hashTable;
111111
std::atomic<unsigned> nextLevel;
112112

113-
bool checkConsistency(const HashTable* oldValue) noexcept;
113+
bool checkConsistency(HashTable* oldValue);
114114
HashTable* waitForMutex(Word** checkWordPtr = nullptr);
115115

116116
class Segment
117117
{
118118
public:
119-
Segment() noexcept;
120-
Word* getSpace(FB_SIZE_T len DIC_STAT_SEGMENT_PAR) noexcept;
121-
static constexpr unsigned getWordCapacity() noexcept;
119+
Segment();
120+
Word* getSpace(FB_SIZE_T l DIC_STAT_SEGMENT_PAR);
121+
static unsigned getWordCapacity();
122122

123123
private:
124-
static constexpr unsigned getWordLength(FB_SIZE_T len) noexcept;
124+
static unsigned getWordLength(FB_SIZE_T len);
125125

126126
#if GROW_DEBUG > 1
127-
static constexpr unsigned SEG_BUFFER_SIZE = 256; // size in sizeof(pointer)
127+
static const unsigned SEG_BUFFER_SIZE = 256; // size in sizeof(pointer)
128128
#else
129-
static constexpr unsigned SEG_BUFFER_SIZE = 16384; // size in sizeof(pointer)
129+
static const unsigned SEG_BUFFER_SIZE = 16384; // size in sizeof(pointer)
130130
#endif
131131
void* buffer[SEG_BUFFER_SIZE];
132132
std::atomic<unsigned> position;
@@ -141,7 +141,7 @@ class MetaName
141141
{
142142
private:
143143
Dictionary::Word* word;
144-
static constexpr const char* EMPTY = "";
144+
static const char* EMPTY;
145145

146146
void test();
147147
Dictionary::Word* get(const char* s, FB_SIZE_T l);
@@ -152,7 +152,7 @@ class MetaName
152152
}
153153

154154
public:
155-
MetaName() noexcept
155+
MetaName()
156156
: word(nullptr)
157157
{ }
158158

@@ -177,7 +177,7 @@ class MetaName
177177
{ }
178178

179179

180-
explicit MetaName(MemoryPool&) noexcept
180+
explicit MetaName(MemoryPool&)
181181
: word(nullptr)
182182
{ }
183183

@@ -233,43 +233,43 @@ class MetaName
233233

234234
MetaName& operator=(const Firebird::MetaString& s);
235235

236-
FB_SIZE_T length() const noexcept
236+
FB_SIZE_T length() const
237237
{
238238
return word ? word->length() : 0;
239239
}
240240

241-
const char* c_str() const noexcept
241+
const char* c_str() const
242242
{
243243
return word ? word->c_str() : EMPTY;
244244
}
245245

246-
const char* nullStr() const noexcept
246+
const char* nullStr() const
247247
{
248248
return word ? word->c_str() : nullptr;
249249
}
250250

251-
bool isEmpty() const noexcept
251+
bool isEmpty() const
252252
{
253253
return !word;
254254
}
255255

256-
bool hasData() const noexcept
256+
bool hasData() const
257257
{
258258
return word;
259259
}
260260

261-
char operator[](unsigned n) const noexcept
261+
char operator[](unsigned n) const
262262
{
263263
fb_assert(n < length());
264264
return word->c_str()[n];
265265
}
266266

267-
const char* begin() const noexcept
267+
const char* begin() const
268268
{
269269
return word ? word->c_str() : EMPTY;
270270
}
271271

272-
const char* end() const noexcept
272+
const char* end() const
273273
{
274274
return word ? &word->c_str()[length()] : EMPTY;
275275
}
@@ -354,22 +354,22 @@ class MetaName
354354
return compare(m) > 0;
355355
}
356356

357-
bool operator==(const MetaName& m) const noexcept
357+
bool operator==(const MetaName& m) const
358358
{
359359
return word == m.word;
360360
}
361361

362-
bool operator!=(const MetaName& m) const noexcept
362+
bool operator!=(const MetaName& m) const
363363
{
364364
return word != m.word;
365365
}
366366

367367
void printf(const char*, ...);
368368
FB_SIZE_T copyTo(char* to, FB_SIZE_T toSize) const;
369-
operator Firebird::MetaString() const noexcept;
369+
operator Firebird::MetaString() const;
370370

371371
protected:
372-
static void adjustLength(const char* const s, FB_SIZE_T& l) noexcept;
372+
static void adjustLength(const char* const s, FB_SIZE_T& l);
373373
};
374374

375375
typedef Firebird::Pair<Firebird::Full<MetaName, MetaName> > MetaNamePair;

0 commit comments

Comments
 (0)