Skip to content

Commit bf48063

Browse files
committed
constexpr + noexcept Relation
1 parent df7b3af commit bf48063

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

src/jrd/Relation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void jrd_rel::retainPages(thread_db* tdbb, TraNumber oldNumber, TraNumber newNum
214214
if (!rel_pages_inst)
215215
return;
216216

217-
SINT64 inst_id = oldNumber;
217+
const SINT64 inst_id = oldNumber;
218218
FB_SIZE_T pos;
219219
if (!rel_pages_inst->find(oldNumber, pos))
220220
return;
@@ -238,12 +238,12 @@ void jrd_rel::getRelLockKey(thread_db* tdbb, UCHAR* key)
238238
memcpy(key, &inst_id, sizeof(inst_id));
239239
}
240240

241-
USHORT jrd_rel::getRelLockKeyLength() const
241+
USHORT jrd_rel::getRelLockKeyLength() const noexcept
242242
{
243243
return sizeof(ULONG) + sizeof(SINT64);
244244
}
245245

246-
void jrd_rel::cleanUp()
246+
void jrd_rel::cleanUp() noexcept
247247
{
248248
delete rel_pages_inst;
249249
rel_pages_inst = NULL;
@@ -306,7 +306,7 @@ void jrd_rel::RelPagesSnapshot::clear()
306306
inherited::clear();
307307
}
308308

309-
bool jrd_rel::hasTriggers() const
309+
bool jrd_rel::hasTriggers() const noexcept
310310
{
311311
typedef const TrigVector* ctv;
312312
ctv trigs[6] = // non-const array, don't want optimization tricks by the compiler.
@@ -505,7 +505,7 @@ int jrd_rel::blocking_ast_gcLock(void* ast_object)
505505

506506
/// jrd_rel::GCExclusive
507507

508-
jrd_rel::GCExclusive::GCExclusive(thread_db* tdbb, jrd_rel* relation) :
508+
jrd_rel::GCExclusive::GCExclusive(thread_db* tdbb, jrd_rel* relation) noexcept :
509509
m_tdbb(tdbb),
510510
m_relation(relation),
511511
m_lock(NULL)

src/jrd/Relation.h

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ViewContext
5353
{
5454
}
5555

56-
static USHORT generate(const ViewContext* vc)
56+
static USHORT generate(const ViewContext* vc) noexcept
5757
{
5858
return vc->vcx_context;
5959
}
@@ -100,14 +100,14 @@ class RelationPages
100100
dpMapMark(0)
101101
{}
102102

103-
inline SLONG addRef()
103+
inline SLONG addRef() noexcept
104104
{
105105
return useCount++;
106106
}
107107

108108
void free(RelationPages*& nextFree);
109109

110-
static inline InstanceId generate(const RelationPages* item)
110+
static inline InstanceId generate(const RelationPages* item) noexcept
111111
{
112112
return item->rel_instance_id;
113113
}
@@ -147,7 +147,7 @@ class RelationPages
147147
}
148148
}
149149

150-
void freeOldestMapItems()
150+
void freeOldestMapItems() noexcept
151151
{
152152
ULONG minMark = MAX_ULONG;
153153
FB_SIZE_T i;
@@ -176,15 +176,15 @@ class RelationPages
176176
RelationPages* rel_next_free;
177177
SLONG useCount;
178178

179-
static const ULONG MAX_DPMAP_ITEMS = 64;
179+
static constexpr ULONG MAX_DPMAP_ITEMS = 64;
180180

181181
struct DPItem
182182
{
183183
ULONG seqNum;
184184
ULONG physNum;
185185
ULONG mark;
186186

187-
static ULONG generate(const DPItem& item)
187+
static ULONG generate(const DPItem& item) noexcept
188188
{
189189
return item.seqNum;
190190
}
@@ -270,12 +270,12 @@ class jrd_rel : public pool_alloc<type_rel>
270270

271271
Firebird::Mutex rel_drop_mutex;
272272

273-
bool isSystem() const;
274-
bool isTemporary() const;
275-
bool isVirtual() const;
276-
bool isView() const;
273+
bool isSystem() const noexcept;
274+
bool isTemporary() const noexcept;
275+
bool isVirtual() const noexcept ;
276+
bool isView() const noexcept;
277277

278-
ObjectType getObjectType() const
278+
ObjectType getObjectType() const noexcept
279279
{
280280
return isView() ? obj_view : obj_relation;
281281
}
@@ -285,7 +285,7 @@ class jrd_rel : public pool_alloc<type_rel>
285285
// global temporary relations attributes
286286
RelationPages* getPages(thread_db* tdbb, TraNumber tran = MAX_TRA_NUMBER, bool allocPages = true);
287287

288-
RelationPages* getBasePages()
288+
RelationPages* getBasePages() noexcept
289289
{
290290
return &rel_pages_base;
291291
}
@@ -294,9 +294,9 @@ class jrd_rel : public pool_alloc<type_rel>
294294
void retainPages(thread_db* tdbb, TraNumber oldNumber, TraNumber newNumber);
295295

296296
void getRelLockKey(thread_db* tdbb, UCHAR* key);
297-
USHORT getRelLockKeyLength() const;
297+
USHORT getRelLockKeyLength() const noexcept;
298298

299-
void cleanUp();
299+
void cleanUp() noexcept;
300300

301301
class RelPagesSnapshot : public Firebird::Array<RelationPages*>
302302
{
@@ -338,7 +338,7 @@ class jrd_rel : public pool_alloc<type_rel>
338338
public:
339339
explicit jrd_rel(MemoryPool& p);
340340

341-
bool hasTriggers() const;
341+
bool hasTriggers() const noexcept;
342342
void releaseTriggers(thread_db* tdbb, bool destroy);
343343
void replaceTriggers(thread_db* tdbb, TrigVector** triggers);
344344

@@ -356,7 +356,7 @@ class jrd_rel : public pool_alloc<type_rel>
356356
GCShared(thread_db* tdbb, jrd_rel* relation);
357357
~GCShared();
358358

359-
bool gcEnabled() const
359+
bool gcEnabled() const noexcept
360360
{
361361
return m_gcEnabled;
362362
}
@@ -372,7 +372,7 @@ class jrd_rel : public pool_alloc<type_rel>
372372
class GCExclusive
373373
{
374374
public:
375-
GCExclusive(thread_db* tdbb, jrd_rel* relation);
375+
GCExclusive(thread_db* tdbb, jrd_rel* relation) noexcept;
376376
~GCExclusive();
377377

378378
bool acquire(int wait);
@@ -387,23 +387,23 @@ class jrd_rel : public pool_alloc<type_rel>
387387

388388
// rel_flags
389389

390-
const ULONG REL_scanned = 0x0001; // Field expressions scanned (or being scanned)
391-
const ULONG REL_system = 0x0002;
392-
const ULONG REL_deleted = 0x0004; // Relation known gonzo
393-
const ULONG REL_get_dependencies = 0x0008; // New relation needs dependencies during scan
394-
const ULONG REL_check_existence = 0x0010; // Existence lock released pending drop of relation
395-
const ULONG REL_blocking = 0x0020; // Blocking someone from dropping relation
396-
const ULONG REL_sql_relation = 0x0080; // Relation defined as sql table
397-
const ULONG REL_check_partners = 0x0100; // Rescan primary dependencies and foreign references
398-
const ULONG REL_being_scanned = 0x0200; // relation scan in progress
399-
const ULONG REL_deleting = 0x0800; // relation delete in progress
400-
const ULONG REL_temp_tran = 0x1000; // relation is a GTT delete rows
401-
const ULONG REL_temp_conn = 0x2000; // relation is a GTT preserve rows
402-
const ULONG REL_virtual = 0x4000; // relation is virtual
403-
const ULONG REL_jrd_view = 0x8000; // relation is VIEW
404-
const ULONG REL_gc_blocking = 0x10000; // request to downgrade\release gc lock
405-
const ULONG REL_gc_disabled = 0x20000; // gc is disabled temporarily
406-
const ULONG REL_gc_lockneed = 0x40000; // gc lock should be acquired
390+
inline constexpr ULONG REL_scanned = 0x0001; // Field expressions scanned (or being scanned)
391+
inline constexpr ULONG REL_system = 0x0002;
392+
inline constexpr ULONG REL_deleted = 0x0004; // Relation known gonzo
393+
inline constexpr ULONG REL_get_dependencies = 0x0008; // New relation needs dependencies during scan
394+
inline constexpr ULONG REL_check_existence = 0x0010; // Existence lock released pending drop of relation
395+
inline constexpr ULONG REL_blocking = 0x0020; // Blocking someone from dropping relation
396+
inline constexpr ULONG REL_sql_relation = 0x0080; // Relation defined as sql table
397+
inline constexpr ULONG REL_check_partners = 0x0100; // Rescan primary dependencies and foreign references
398+
inline constexpr ULONG REL_being_scanned = 0x0200; // relation scan in progress
399+
inline constexpr ULONG REL_deleting = 0x0800; // relation delete in progress
400+
inline constexpr ULONG REL_temp_tran = 0x1000; // relation is a GTT delete rows
401+
inline constexpr ULONG REL_temp_conn = 0x2000; // relation is a GTT preserve rows
402+
inline constexpr ULONG REL_virtual = 0x4000; // relation is virtual
403+
inline constexpr ULONG REL_jrd_view = 0x8000; // relation is VIEW
404+
inline constexpr ULONG REL_gc_blocking = 0x10000; // request to downgrade\release gc lock
405+
inline constexpr ULONG REL_gc_disabled = 0x20000; // gc is disabled temporarily
406+
inline constexpr ULONG REL_gc_lockneed = 0x40000; // gc lock should be acquired
407407

408408

409409
/// class jrd_rel
@@ -416,22 +416,22 @@ inline jrd_rel::jrd_rel(MemoryPool& p)
416416
{
417417
}
418418

419-
inline bool jrd_rel::isSystem() const
419+
inline bool jrd_rel::isSystem() const noexcept
420420
{
421421
return rel_flags & REL_system;
422422
}
423423

424-
inline bool jrd_rel::isTemporary() const
424+
inline bool jrd_rel::isTemporary() const noexcept
425425
{
426426
return (rel_flags & (REL_temp_tran | REL_temp_conn));
427427
}
428428

429-
inline bool jrd_rel::isVirtual() const
429+
inline bool jrd_rel::isVirtual() const noexcept
430430
{
431431
return (rel_flags & REL_virtual);
432432
}
433433

434-
inline bool jrd_rel::isView() const
434+
inline bool jrd_rel::isView() const noexcept
435435
{
436436
return (rel_flags & REL_jrd_view);
437437
}
@@ -479,7 +479,7 @@ inline jrd_rel::GCShared::~GCShared()
479479

480480
// Field block, one for each field in a scanned relation
481481

482-
const USHORT FLD_parse_computed = 0x0001; // computed expression is being parsed
482+
inline constexpr USHORT FLD_parse_computed = 0x0001; // computed expression is being parsed
483483

484484
class jrd_fld : public pool_alloc<type_fld>
485485
{

0 commit comments

Comments
 (0)