Skip to content

Commit bbad333

Browse files
committed
constexpr + noexcept in exe
1 parent 61a0e5e commit bbad333

File tree

4 files changed

+131
-119
lines changed

4 files changed

+131
-119
lines changed

src/jrd/exe.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ string Item::getDescription(Request* request, const ItemInfo* itemInfo) const
123123
if (itemInfo && itemInfo->name.hasData())
124124
return itemInfo->name.toQuotedString();
125125

126-
int oneBasedIndex = index + 1;
126+
const int oneBasedIndex = index + 1;
127127
string s;
128128

129129
if (type == Item::TYPE_VARIABLE)
@@ -156,23 +156,23 @@ string Item::getDescription(Request* request, const ItemInfo* itemInfo) const
156156

157157
// AffectedRows class implementation
158158

159-
AffectedRows::AffectedRows()
159+
AffectedRows::AffectedRows() noexcept
160160
{
161161
clear();
162162
}
163163

164-
void AffectedRows::clear()
164+
void AffectedRows::clear() noexcept
165165
{
166166
writeFlag = false;
167167
fetchedRows = modifiedRows = 0;
168168
}
169169

170-
void AffectedRows::bumpFetched()
170+
void AffectedRows::bumpFetched() noexcept
171171
{
172172
fetchedRows++;
173173
}
174174

175-
void AffectedRows::bumpModified(bool increment)
175+
void AffectedRows::bumpModified(bool increment) noexcept
176176
{
177177
if (increment) {
178178
modifiedRows++;
@@ -182,7 +182,7 @@ void AffectedRows::bumpModified(bool increment)
182182
}
183183
}
184184

185-
int AffectedRows::getCount() const
185+
int AffectedRows::getCount() const noexcept
186186
{
187187
return writeFlag ? modifiedRows : fetchedRows;
188188
}
@@ -200,12 +200,12 @@ void StatusXcp::clear()
200200
status->init();
201201
}
202202

203-
void StatusXcp::init(const FbStatusVector* vector)
203+
void StatusXcp::init(const FbStatusVector* vector) noexcept
204204
{
205205
fb_utils::copyStatus(&status, vector);
206206
}
207207

208-
void StatusXcp::copyTo(FbStatusVector* vector) const
208+
void StatusXcp::copyTo(FbStatusVector* vector) const noexcept
209209
{
210210
fb_utils::copyStatus(vector, &status);
211211
}
@@ -261,7 +261,7 @@ static void release_blobs(thread_db*, Request*);
261261
static void trigger_failure(thread_db*, Request*);
262262
static void stuff_stack_trace(const Request*);
263263

264-
const size_t MAX_STACK_TRACE = 2048;
264+
constexpr size_t MAX_STACK_TRACE = 2048;
265265

266266

267267
namespace
@@ -1375,6 +1375,10 @@ void EXE_execute_triggers(thread_db* tdbb,
13751375
case TriggerAction::TRIGGER_INSERT:
13761376
SystemTriggers::executeBeforeInsertTriggers(tdbb, relation, new_rec);
13771377
break;
1378+
1379+
default:
1380+
// other trigger actions not relevant here
1381+
break;
13781382
}
13791383
break;
13801384
}
@@ -1385,8 +1389,16 @@ void EXE_execute_triggers(thread_db* tdbb,
13851389
case TriggerAction::TRIGGER_DELETE:
13861390
SystemTriggers::executeAfterDeleteTriggers(tdbb, relation, old_rec);
13871391
break;
1392+
1393+
default:
1394+
// other trigger actions not relevant here
1395+
break;
13881396
}
13891397
break;
1398+
1399+
default:
1400+
// other trigger types not relevant here
1401+
break;
13901402
}
13911403
}
13921404
}

src/jrd/exe.h

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -95,33 +95,33 @@ enum SortDirection { ORDER_ANY, ORDER_ASC, ORDER_DESC };
9595
enum NullsPlacement { NULLS_DEFAULT, NULLS_FIRST, NULLS_LAST };
9696

9797
// CompilerScratch.csb_g_flags' values.
98-
const int csb_internal = 1; // "csb_g_flag" switch
99-
const int csb_get_dependencies = 2; // we are retrieving dependencies
100-
const int csb_ignore_perm = 4; // ignore permissions checks
101-
//const int csb_blr_version4 = 8; // the BLR is of version 4
102-
const int csb_pre_trigger = 16; // this is a BEFORE trigger
103-
const int csb_post_trigger = 32; // this is an AFTER trigger
104-
const int csb_validation = 64; // we're in a validation expression (RDB hack)
105-
const int csb_reuse_context = 128; // allow context reusage
106-
const int csb_subroutine = 256; // sub routine
107-
const int csb_reload = 512; // request's BLR should be loaded and parsed again
108-
const int csb_computed_field = 1024; // computed field expression
109-
const int csb_search_system_schema = 2048; // search system schema
98+
inline constexpr int csb_internal = 1; // "csb_g_flag" switch
99+
inline constexpr int csb_get_dependencies = 2; // we are retrieving dependencies
100+
inline constexpr int csb_ignore_perm = 4; // ignore permissions checks
101+
//inline constexpr int csb_blr_version4 = 8; // the BLR is of version 4
102+
inline constexpr int csb_pre_trigger = 16; // this is a BEFORE trigger
103+
inline constexpr int csb_post_trigger = 32; // this is an AFTER trigger
104+
inline constexpr int csb_validation = 64; // we're in a validation expression (RDB hack)
105+
inline constexpr int csb_reuse_context = 128; // allow context reusage
106+
inline constexpr int csb_subroutine = 256; // sub routine
107+
inline constexpr int csb_reload = 512; // request's BLR should be loaded and parsed again
108+
inline constexpr int csb_computed_field = 1024; // computed field expression
109+
inline constexpr int csb_search_system_schema = 2048; // search system schema
110110

111111
// CompilerScratch.csb_rpt[].csb_flags's values.
112-
const int csb_active = 1; // stream is active
113-
const int csb_used = 2; // context has already been defined (BLR parsing only)
114-
const int csb_view_update = 4; // view update w/wo trigger is in progress
115-
const int csb_trigger = 8; // NEW or OLD context in trigger
116-
//const int csb_no_dbkey = 16; // unused
117-
const int csb_store = 32; // we are processing a store statement
118-
const int csb_modify = 64; // we are processing a modify
119-
const int csb_sub_stream = 128; // a sub-stream of the RSE being processed
120-
const int csb_erase = 256; // we are processing an erase
121-
const int csb_unmatched = 512; // stream has conjuncts unmatched by any index
122-
const int csb_update = 1024; // erase or modify for relation
123-
const int csb_unstable = 2048; // unstable explicit cursor
124-
const int csb_skip_locked = 4096; // skip locked record
112+
inline constexpr int csb_active = 1; // stream is active
113+
inline constexpr int csb_used = 2; // context has already been defined (BLR parsing only)
114+
inline constexpr int csb_view_update = 4; // view update w/wo trigger is in progress
115+
inline constexpr int csb_trigger = 8; // NEW or OLD context in trigger
116+
//inline constexpr int csb_no_dbkey = 16; // unused
117+
inline constexpr int csb_store = 32; // we are processing a store statement
118+
inline constexpr int csb_modify = 64; // we are processing a modify
119+
inline constexpr int csb_sub_stream = 128; // a sub-stream of the RSE being processed
120+
inline constexpr int csb_erase = 256; // we are processing an erase
121+
inline constexpr int csb_unmatched = 512; // stream has conjuncts unmatched by any index
122+
inline constexpr int csb_update = 1024; // erase or modify for relation
123+
inline constexpr int csb_unstable = 2048; // unstable explicit cursor
124+
inline constexpr int csb_skip_locked = 4096; // skip locked record
125125

126126

127127
// Aggregate Sort Block (for DISTINCT aggregates)
@@ -185,7 +185,7 @@ struct Resource
185185
Routine* rsc_routine; // Routine block
186186
Collation* rsc_coll; // Collation block
187187

188-
static bool greaterThan(const Resource& i1, const Resource& i2)
188+
static bool greaterThan(const Resource& i1, const Resource& i2) noexcept
189189
{
190190
// A few places of the engine depend on fact that rsc_type
191191
// is the first field in ResourceList ordering
@@ -200,7 +200,7 @@ struct Resource
200200
return i1.rsc_id > i2.rsc_id;
201201
}
202202

203-
Resource(rsc_s type, USHORT id, jrd_rel* rel, Routine* routine, Collation* coll)
203+
Resource(rsc_s type, USHORT id, jrd_rel* rel, Routine* routine, Collation* coll) noexcept
204204
: rsc_type(type), rsc_id(id), rsc_rel(rel), rsc_routine(routine), rsc_coll(coll)
205205
{ }
206206
};
@@ -327,14 +327,14 @@ struct Item
327327
TYPE_CAST
328328
};
329329

330-
Item(Type aType, UCHAR aSubType, USHORT aIndex)
330+
Item(Type aType, UCHAR aSubType, USHORT aIndex) noexcept
331331
: type(aType),
332332
subType(aSubType),
333333
index(aIndex)
334334
{
335335
}
336336

337-
Item(Type aType, USHORT aIndex = 0)
337+
Item(Type aType, USHORT aIndex = 0) noexcept
338338
: type(aType),
339339
subType(0),
340340
index(aIndex)
@@ -345,7 +345,7 @@ struct Item
345345
UCHAR subType;
346346
USHORT index;
347347

348-
bool operator >(const Item& x) const
348+
bool operator >(const Item& x) const noexcept
349349
{
350350
if (type == x.type)
351351
{
@@ -363,7 +363,7 @@ struct Item
363363

364364
struct FieldInfo
365365
{
366-
FieldInfo()
366+
FieldInfo() noexcept
367367
: nullable(false), defaultValue(NULL), validationExpr(NULL)
368368
{}
369369

@@ -393,7 +393,7 @@ class ItemInfo : public Printable
393393
{
394394
}
395395

396-
ItemInfo()
396+
ItemInfo() noexcept
397397
: name(),
398398
field(),
399399
nullable(true),
@@ -403,7 +403,7 @@ class ItemInfo : public Printable
403403
}
404404

405405
public:
406-
bool isSpecial() const
406+
bool isSpecial() const noexcept
407407
{
408408
return !nullable || fullDomain;
409409
}
@@ -543,7 +543,7 @@ class CompilerScratch : public pool_alloc<type_csb>
543543
return csb_n_stream++;
544544
}
545545

546-
bool collectingDependencies() const
546+
bool collectingDependencies() const noexcept
547547
{
548548
return (mainCsb ? mainCsb : this)->csb_g_flags & csb_get_dependencies;
549549
}
@@ -654,10 +654,10 @@ class CompilerScratch : public pool_alloc<type_csb>
654654
struct csb_repeat
655655
{
656656
// We must zero-initialize this one
657-
csb_repeat();
657+
csb_repeat() noexcept;
658658

659-
void activate();
660-
void deactivate();
659+
void activate() noexcept;
660+
void deactivate() noexcept;
661661
QualifiedName getName(bool allowEmpty = true) const;
662662

663663
std::optional<USHORT> csb_cursor_number; // Cursor number for this stream
@@ -688,7 +688,7 @@ class CompilerScratch : public pool_alloc<type_csb>
688688
};
689689

690690
// We must zero-initialize this one
691-
inline CompilerScratch::csb_repeat::csb_repeat()
691+
inline CompilerScratch::csb_repeat::csb_repeat() noexcept
692692
: csb_stream(0),
693693
csb_view_stream(0),
694694
csb_flags(0),
@@ -709,12 +709,12 @@ inline CompilerScratch::csb_repeat::csb_repeat()
709709
{
710710
}
711711

712-
inline void CompilerScratch::csb_repeat::activate()
712+
inline void CompilerScratch::csb_repeat::activate() noexcept
713713
{
714714
csb_flags |= csb_active;
715715
}
716716

717-
inline void CompilerScratch::csb_repeat::deactivate()
717+
inline void CompilerScratch::csb_repeat::deactivate() noexcept
718718
{
719719
csb_flags &= ~csb_active;
720720
}
@@ -756,8 +756,8 @@ class StatusXcp
756756
StatusXcp();
757757

758758
void clear();
759-
void init(const Jrd::FbStatusVector*);
760-
void copyTo(Jrd::FbStatusVector*) const;
759+
void init(const Jrd::FbStatusVector*) noexcept;
760+
void copyTo(Jrd::FbStatusVector*) const noexcept;
761761
bool success() const;
762762
SLONG as_gdscode() const;
763763
SLONG as_sqlcode() const;
@@ -767,7 +767,7 @@ class StatusXcp
767767
};
768768

769769
// must correspond to the declared size of RDB$EXCEPTIONS.RDB$MESSAGE
770-
const unsigned XCP_MESSAGE_LENGTH = 1023;
770+
inline constexpr unsigned XCP_MESSAGE_LENGTH = 1023;
771771

772772
// Array which stores relative pointers to impure areas of invariant nodes
773773
typedef Firebird::SortedArray<ULONG> VarInvariantArray;

src/jrd/exe_proto.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace Jrd
7272
CachedRequestId& operator=(const CachedRequestId&) = delete;
7373

7474
public:
75-
USHORT getId() const
75+
USHORT getId() const noexcept
7676
{
7777
return id;
7878
}
@@ -101,7 +101,7 @@ namespace Jrd
101101
{
102102
}
103103

104-
AutoCacheRequest()
104+
AutoCacheRequest() noexcept
105105
: id(0),
106106
which(0),
107107
request(NULL)
@@ -141,17 +141,17 @@ namespace Jrd
141141
cacheRequest();
142142
}
143143

144-
Request* operator ->()
144+
Request* operator ->() noexcept
145145
{
146146
return request;
147147
}
148148

149-
operator Request*()
149+
operator Request*() noexcept
150150
{
151151
return request;
152152
}
153153

154-
bool operator !() const
154+
bool operator !() const noexcept
155155
{
156156
return !request;
157157
}
@@ -177,7 +177,7 @@ namespace Jrd
177177
class AutoRequest
178178
{
179179
public:
180-
AutoRequest()
180+
AutoRequest() noexcept
181181
: request(NULL)
182182
{
183183
}
@@ -201,17 +201,17 @@ namespace Jrd
201201
request = CMP_compile_request(tdbb, blr, blrLength, true);
202202
}
203203

204-
Request* operator ->()
204+
Request* operator ->() noexcept
205205
{
206206
return request;
207207
}
208208

209-
operator Request*()
209+
operator Request*() noexcept
210210
{
211211
return request;
212212
}
213213

214-
bool operator !() const
214+
bool operator !() const noexcept
215215
{
216216
return !request;
217217
}

0 commit comments

Comments
 (0)