Skip to content

Commit c9441fe

Browse files
committed
constexpr StatementMetadata
1 parent ed83fb6 commit c9441fe

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/common/StatementMetadata.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
namespace Firebird {
3535

3636

37-
static const UCHAR DESCRIBE_VARS[] =
37+
static constexpr UCHAR DESCRIBE_VARS[] =
3838
{
3939
isc_info_sql_describe_vars,
4040
isc_info_sql_sqlda_seq,
@@ -50,7 +50,7 @@ static const UCHAR DESCRIBE_VARS[] =
5050
isc_info_sql_describe_end
5151
};
5252

53-
static const unsigned INFO_BUFFER_SIZE = MemoryPool::MAX_MEDIUM_BLOCK_SIZE;
53+
static constexpr unsigned INFO_BUFFER_SIZE = MemoryPool::MAX_MEDIUM_BLOCK_SIZE;
5454

5555

5656
static USHORT getLen(const UCHAR** ptr, const UCHAR* bufferEnd);
@@ -93,7 +93,7 @@ unsigned StatementMetadata::buildInfoItems(Array<UCHAR>& items, unsigned flags)
9393
}
9494

9595
// Build a prepare flags bitmask based on a list of info codes.
96-
unsigned StatementMetadata::buildInfoFlags(unsigned itemsLength, const UCHAR* items)
96+
unsigned StatementMetadata::buildInfoFlags(unsigned itemsLength, const UCHAR* items) noexcept
9797
{
9898
unsigned flags = 0;
9999
const UCHAR* end = items + itemsLength;
@@ -137,7 +137,7 @@ unsigned StatementMetadata::getType()
137137
{
138138
if (!type.has_value())
139139
{
140-
UCHAR info[] = {isc_info_sql_stmt_type};
140+
constexpr UCHAR info[] = {isc_info_sql_stmt_type};
141141
UCHAR result[16];
142142

143143
getAndParse(sizeof(info), info, sizeof(result), result);
@@ -152,7 +152,7 @@ unsigned StatementMetadata::getFlags()
152152
{
153153
if (!flags.has_value())
154154
{
155-
UCHAR info[] = {isc_info_sql_stmt_flags};
155+
constexpr UCHAR info[] = {isc_info_sql_stmt_flags};
156156
UCHAR result[16];
157157

158158
getAndParse(sizeof(info), info, sizeof(result), result);
@@ -166,11 +166,11 @@ unsigned StatementMetadata::getFlags()
166166
// Get statement plan.
167167
const char* StatementMetadata::getPlan(bool detailed)
168168
{
169-
string* plan = detailed ? &detailedPlan : &legacyPlan;
169+
const string* plan = detailed ? &detailedPlan : &legacyPlan;
170170

171171
if (plan->isEmpty())
172172
{
173-
UCHAR info[] = {UCHAR(detailed ? isc_info_sql_explain_plan : isc_info_sql_get_plan)};
173+
const UCHAR info[] = {UCHAR(detailed ? isc_info_sql_explain_plan : isc_info_sql_get_plan)};
174174
UCHAR result[INFO_BUFFER_SIZE];
175175

176176
getAndParse(sizeof(info), info, sizeof(result), result);
@@ -202,7 +202,7 @@ IMessageMetadata* StatementMetadata::getOutputMetadata()
202202
// Get number of records affected by the statement execution.
203203
ISC_UINT64 StatementMetadata::getAffectedRecords()
204204
{
205-
UCHAR info[] = {isc_info_sql_records};
205+
constexpr UCHAR info[] = {isc_info_sql_records};
206206
UCHAR result[33];
207207

208208
getAndParse(sizeof(info), info, sizeof(result), result);
@@ -215,7 +215,7 @@ ISC_UINT64 StatementMetadata::getAffectedRecords()
215215

216216
while (*p != isc_info_end)
217217
{
218-
UCHAR counter = *p++;
218+
const UCHAR counter = *p++;
219219
const SSHORT len = gds__vax_integer(p, 2);
220220
p += 2;
221221
if (counter != isc_info_req_select_count)
@@ -308,7 +308,7 @@ void StatementMetadata::parse(unsigned bufferLength, const UCHAR* buffer)
308308
case isc_info_sql_sqlda_seq:
309309
if (!parameters->fetched)
310310
{
311-
unsigned num = getNumericInfo(&buffer, bufferEnd);
311+
const unsigned num = getNumericInfo(&buffer, bufferEnd);
312312

313313
while (parameters->items.getCount() < num)
314314
parameters->items.add();
@@ -379,7 +379,7 @@ void StatementMetadata::parse(unsigned bufferLength, const UCHAR* buffer)
379379

380380
for (unsigned n = 0; n < parameters->items.getCount(); ++n)
381381
{
382-
Parameters::Item* param = &parameters->items[n];
382+
const Parameters::Item* param = &parameters->items[n];
383383

384384
if (!param->finished)
385385
{
@@ -532,7 +532,7 @@ static USHORT getLen(const UCHAR** ptr, const UCHAR* bufferEnd)
532532
static int getNumericInfo(const UCHAR** ptr, const UCHAR* bufferEnd)
533533
{
534534
const USHORT len = getLen(ptr, bufferEnd);
535-
int item = gds__vax_integer(*ptr, len);
535+
const int item = gds__vax_integer(*ptr, len);
536536
*ptr += len;
537537
return item;
538538
}

src/common/StatementMetadata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class StatementMetadata : public PermanentStorage
6363
}
6464

6565
static unsigned buildInfoItems(Array<UCHAR>& items, unsigned flags);
66-
static unsigned buildInfoFlags(unsigned itemsLength, const UCHAR* items);
66+
static unsigned buildInfoFlags(unsigned itemsLength, const UCHAR* items) noexcept;
6767

6868
unsigned getType();
6969
unsigned getFlags();

0 commit comments

Comments
 (0)