Skip to content

Commit 6d56ec8

Browse files
committed
constexpr + noexcept HashJoin
1 parent c157a2c commit 6d56ec8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/jrd/recsrc/HashJoin.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ using namespace Jrd;
4444
// ----------------------
4545

4646
// NS: FIXME - Why use static hash table here??? Hash table shall support dynamic resizing
47-
static const ULONG HASH_SIZE = 1009;
48-
static const ULONG BUCKET_PREALLOCATE_SIZE = 32; // 256 bytes per bucket
47+
static constexpr ULONG HASH_SIZE = 1009;
48+
static constexpr ULONG BUCKET_PREALLOCATE_SIZE = 32; // 256 bytes per bucket
4949

50-
unsigned HashJoin::maxCapacity()
50+
unsigned HashJoin::maxCapacity() noexcept
5151
{
5252
// Binary search across 1000 collisions is computationally similar to
5353
// linear search across 10 collisions. We use this number as a rough
@@ -56,23 +56,23 @@ unsigned HashJoin::maxCapacity()
5656
}
5757

5858

59-
class HashJoin::HashTable : public PermanentStorage
59+
class HashJoin::HashTable final : public PermanentStorage
6060
{
6161
class CollisionList
6262
{
63-
static const FB_SIZE_T INVALID_ITERATOR = FB_SIZE_T(~0);
63+
static constexpr FB_SIZE_T INVALID_ITERATOR = FB_SIZE_T(~0);
6464

6565
struct Entry
6666
{
67-
Entry()
67+
Entry() noexcept
6868
: hash(0), position(0)
6969
{}
7070

71-
Entry(ULONG h, ULONG pos)
71+
Entry(ULONG h, ULONG pos) noexcept
7272
: hash(h), position(pos)
7373
{}
7474

75-
static const ULONG generate(const Entry& item)
75+
static const ULONG generate(const Entry& item) noexcept
7676
{
7777
return item.hash;
7878
}
@@ -94,7 +94,7 @@ class HashJoin::HashTable : public PermanentStorage
9494
m_collisions.sort();
9595
}
9696

97-
ULONG getCount() const
97+
ULONG getCount() const noexcept
9898
{
9999
return (ULONG) m_collisions.getCount();
100100
}
@@ -113,7 +113,7 @@ class HashJoin::HashTable : public PermanentStorage
113113
return false;
114114
}
115115

116-
bool iterate(ULONG hash, ULONG& position)
116+
bool iterate(ULONG hash, ULONG& position) noexcept
117117
{
118118
if (m_iterator >= m_collisions.getCount())
119119
return false;
@@ -197,7 +197,7 @@ class HashJoin::HashTable : public PermanentStorage
197197
collisions->locate(hash);
198198
}
199199

200-
bool iterate(ULONG stream, ULONG hash, ULONG& position)
200+
bool iterate(ULONG stream, ULONG hash, ULONG& position) noexcept
201201
{
202202
fb_assert(stream < m_streamCount);
203203

@@ -404,7 +404,7 @@ bool HashJoin::internalGetRecord(thread_db* tdbb) const
404404
if (!(impure->irsb_flags & irsb_open))
405405
return false;
406406

407-
const auto inner = m_subs.front().source;
407+
const auto* const inner = m_subs.front().source;
408408

409409
while (true)
410410
{
@@ -589,7 +589,7 @@ ULONG HashJoin::computeHash(thread_db* tdbb,
589589
}
590590
else
591591
{
592-
const auto data = desc->dsc_address;
592+
const auto* const data = desc->dsc_address;
593593

594594
if (desc->isDecFloat())
595595
{

src/jrd/recsrc/RecordSource.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ namespace Jrd
13051305
const StreamList m_checkStreams;
13061306
};
13071307

1308-
class HashJoin : public Join<RecordSource>
1308+
class HashJoin final : public Join<RecordSource>
13091309
{
13101310
class HashTable;
13111311

@@ -1341,7 +1341,7 @@ namespace Jrd
13411341
void close(thread_db* tdbb) const override;
13421342
void getLegacyPlan(thread_db* tdbb, Firebird::string& plan, unsigned level) const override;
13431343

1344-
static unsigned maxCapacity();
1344+
static unsigned maxCapacity() noexcept;
13451345

13461346
protected:
13471347
void internalGetPlan(thread_db* tdbb, PlanEntry& planEntry, unsigned level, bool recurse) const override;

0 commit comments

Comments
 (0)