Skip to content

Commit 2aa2f31

Browse files
committed
constexpr + noexcept in Optimizer
1 parent 626fc48 commit 2aa2f31

File tree

2 files changed

+72
-72
lines changed

2 files changed

+72
-72
lines changed

src/jrd/optimizer/Optimizer.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,21 @@ using namespace Firebird;
106106

107107
namespace
108108
{
109-
inline void SET_DEP_BIT(ULONG* array, const SLONG bit)
109+
inline void SET_DEP_BIT(ULONG* array, const SLONG bit) noexcept
110110
{
111111
array[bit / BITS_PER_LONG] |= (1L << (bit % BITS_PER_LONG));
112112
}
113113

114-
inline bool TEST_DEP_BIT(const ULONG* array, const ULONG bit)
114+
inline bool TEST_DEP_BIT(const ULONG* array, const ULONG bit) noexcept
115115
{
116116
return (array[bit / BITS_PER_LONG] & (1L << (bit % BITS_PER_LONG))) != 0;
117117
}
118118

119-
const int CACHE_PAGES_PER_STREAM = 15;
119+
constexpr int CACHE_PAGES_PER_STREAM = 15;
120120

121121
// enumeration of sort datatypes
122122

123-
static const UCHAR sort_dtypes[] =
123+
static constexpr UCHAR sort_dtypes[] =
124124
{
125125
0, // dtype_unknown
126126
SKD_text, // dtype_text
@@ -153,10 +153,10 @@ namespace
153153

154154
struct SortField
155155
{
156-
SortField() : stream(INVALID_STREAM), id(0), desc(nullptr)
156+
SortField() noexcept : stream(INVALID_STREAM), id(0), desc(nullptr)
157157
{}
158158

159-
SortField(StreamType _stream, ULONG _id, const dsc* _desc)
159+
SortField(StreamType _stream, ULONG _id, const dsc* _desc) noexcept
160160
: stream(_stream), id(_id), desc(_desc)
161161
{}
162162

@@ -165,7 +165,7 @@ namespace
165165
const dsc* desc;
166166
};
167167

168-
class CrossJoin : public River
168+
class CrossJoin final : public River
169169
{
170170
public:
171171
CrossJoin(Optimizer* opt, RiverList& rivers, JoinType joinType)
@@ -295,7 +295,7 @@ namespace
295295
}
296296
}
297297

298-
unsigned getRiverCount(unsigned count, const ValueExprNode* const* eq_class)
298+
unsigned getRiverCount(unsigned count, const ValueExprNode* const* eq_class) noexcept
299299
{
300300
// Given an sort/merge join equivalence class (vector of node pointers
301301
// of representative values for rivers), return the count of rivers with values
@@ -437,7 +437,7 @@ namespace
437437

438438
// If there were none indices, this is a sequential retrieval.
439439

440-
const auto relation = tail->csb_relation;
440+
const auto* relation = tail->csb_relation;
441441
if (!relation)
442442
return;
443443

@@ -527,7 +527,7 @@ namespace
527527
return false;
528528
}
529529

530-
void setDirection(SortNode* fromClause, SortNode* toClause)
530+
void setDirection(SortNode* fromClause, SortNode* toClause) noexcept
531531
{
532532
// Update the direction of a GROUP BY, DISTINCT, or ORDER BY
533533
// clause to the same direction as another clause. Do the same
@@ -568,7 +568,7 @@ namespace
568568
for (const auto from_end = from_ptr + count; from_ptr != from_end; ++from_ptr)
569569
{
570570
NestConst<ValueExprNode>* to_ptr = to_clause->expressions.begin();
571-
for (const auto to_end = to_ptr + count; to_ptr != to_end; ++to_ptr)
571+
for (const auto* to_end = to_ptr + count; to_ptr != to_end; ++to_ptr)
572572
{
573573
if ((map && mapEqual(*to_ptr, *from_ptr, map)) ||
574574
(!map && fieldEqual(*to_ptr, *from_ptr)))
@@ -1505,7 +1505,7 @@ SortedStream* Optimizer::generateSort(const StreamList& streams,
15051505

15061506
if (!refetchFlag)
15071507
{
1508-
const auto dbb = tdbb->getDatabase();
1508+
const auto* dbb = tdbb->getDatabase();
15091509
const auto threshold = dbb->dbb_config->getInlineSortThreshold();
15101510

15111511
refetchFlag = (totalLength > threshold);
@@ -1518,7 +1518,7 @@ SortedStream* Optimizer::generateSort(const StreamList& streams,
15181518
{
15191519
for (auto& item : fields)
15201520
{
1521-
const auto relation = csb->csb_rpt[item.stream].csb_relation;
1521+
const auto* relation = csb->csb_rpt[item.stream].csb_relation;
15221522

15231523
if (relation &&
15241524
!relation->rel_file &&
@@ -1753,7 +1753,7 @@ void Optimizer::checkIndices()
17531753
if (plan->type != PlanNode::TYPE_RETRIEVE)
17541754
continue;
17551755

1756-
const auto relation = tail->csb_relation;
1756+
const auto* relation = tail->csb_relation;
17571757
if (!relation)
17581758
return;
17591759

@@ -2282,7 +2282,7 @@ void Optimizer::findDependentStreams(const StreamList& streams,
22822282
// SORT/MERGE.
22832283

22842284
Retrieval retrieval(tdbb, this, stream, false, false, nullptr, true);
2285-
const auto candidate = retrieval.getInversion();
2285+
const auto* candidate = retrieval.getInversion();
22862286

22872287
if (candidate->dependentFromStreams.hasData())
22882288
indexed_relationship = true;
@@ -2381,7 +2381,7 @@ bool Optimizer::generateEquiJoin(RiverList& rivers, JoinType joinType)
23812381

23822382
for (River** iter = orgRivers.begin(); iter < orgRivers.end();)
23832383
{
2384-
const auto river = *iter;
2384+
const auto* river = *iter;
23852385

23862386
StreamStateHolder stateHolder2(csb, river->getStreams());
23872387
stateHolder2.activate();
@@ -2528,7 +2528,7 @@ bool Optimizer::generateEquiJoin(RiverList& rivers, JoinType joinType)
25282528

25292529
// Find position of the river with maximum cardinality
25302530

2531-
const auto rsb = river->getRecordSource();
2531+
const auto* rsb = river->getRecordSource();
25322532
const auto cardinality = rsb->getCardinality();
25332533

25342534
if (cardinality > maxCardinality1)
@@ -3010,9 +3010,9 @@ bool Optimizer::getEquiJoinKeys(NestConst<ValueExprNode>& node1,
30103010
string Optimizer::getStreamName(StreamType stream)
30113011
{
30123012
const auto tail = &csb->csb_rpt[stream];
3013-
const auto relation = tail->csb_relation;
3014-
const auto procedure = tail->csb_procedure;
3015-
const auto alias = tail->csb_alias;
3013+
const auto* relation = tail->csb_relation;
3014+
const auto* procedure = tail->csb_procedure;
3015+
const auto* alias = tail->csb_alias;
30163016

30173017
string name = tail->getName().toQuotedString();
30183018

@@ -3164,8 +3164,8 @@ ValueExprNode* Optimizer::optimizeLikeSimilar(ComparativeBoolNode* cmpNode)
31643164

31653165
TextType* matchTextType = INTL_texttype_lookup(tdbb, INTL_TTYPE(&matchDesc));
31663166
CharSet* matchCharset = matchTextType->getCharSet();
3167-
TextType* patternTextType = INTL_texttype_lookup(tdbb, INTL_TTYPE(patternDesc));
3168-
CharSet* patternCharset = patternTextType->getCharSet();
3167+
const TextType* patternTextType = INTL_texttype_lookup(tdbb, INTL_TTYPE(patternDesc));
3168+
const CharSet* patternCharset = patternTextType->getCharSet();
31693169

31703170
if (cmpNode->blrOp == blr_like)
31713171
{
@@ -3272,8 +3272,8 @@ ValueExprNode* Optimizer::optimizeLikeSimilar(ComparativeBoolNode* cmpNode)
32723272

32733273
MoveBuffer patternBuffer;
32743274
UCHAR* patternStart;
3275-
ULONG patternLen = MOV_make_string2(tdbb, patternDesc, INTL_TTYPE(&matchDesc), &patternStart, patternBuffer);
3276-
const auto patternEnd = patternStart + patternLen;
3275+
const ULONG patternLen = MOV_make_string2(tdbb, patternDesc, INTL_TTYPE(&matchDesc), &patternStart, patternBuffer);
3276+
const auto* patternEnd = patternStart + patternLen;
32773277
const UCHAR* patternPtr = patternStart;
32783278

32793279
MoveBuffer prefixBuffer;
@@ -3341,7 +3341,7 @@ ValueExprNode* Optimizer::optimizeLikeSimilar(ComparativeBoolNode* cmpNode)
33413341
}
33423342
}
33433343

3344-
void Optimizer::printf(const char* format, ...)
3344+
void Optimizer::printf(const char* format, ...) noexcept
33453345
{
33463346
#ifndef OPT_DEBUG_SYS_REQUESTS
33473347
if (csb->csb_g_flags & csb_internal)

0 commit comments

Comments
 (0)