Skip to content

Commit e8773de

Browse files
committed
constexpr + noexcept sqz
1 parent bf48063 commit e8773de

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/jrd/sqz.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ using namespace Jrd;
5050

5151
namespace
5252
{
53-
const unsigned MIN_COMPRESS_RUN = 8; // minimal length of compressable run
53+
constexpr unsigned MIN_COMPRESS_RUN = 8; // minimal length of compressable run
5454

55-
const int MAX_NONCOMP_RUN = MAX_SCHAR; // 127
55+
constexpr int MAX_NONCOMP_RUN = MAX_SCHAR; // 127
5656

57-
const int MAX_SHORT_RUN = -MIN_SCHAR; // 128
58-
const int MAX_MEDIUM_RUN = MAX_USHORT; // 2^16
59-
const int MAX_LONG_RUN = MAX_SLONG; // 2^31
57+
constexpr int MAX_SHORT_RUN = -MIN_SCHAR; // 128
58+
constexpr int MAX_MEDIUM_RUN = MAX_USHORT; // 2^16
59+
constexpr int MAX_LONG_RUN = MAX_SLONG; // 2^31
6060

61-
inline int adjustRunLength(unsigned length)
61+
inline int adjustRunLength(unsigned length) noexcept
6262
{
6363
return (length <= MAX_SHORT_RUN) ? 0 :
6464
(length <= MAX_MEDIUM_RUN) ? sizeof(USHORT) : sizeof(ULONG);
@@ -469,7 +469,7 @@ UCHAR* Compressor::unpack(ULONG inLength, const UCHAR* input,
469469
*
470470
**************************************/
471471
const auto end = input + inLength;
472-
const auto output_end = output + outLength;
472+
const auto* const output_end = output + outLength;
473473

474474
while (input < end)
475475
{
@@ -526,9 +526,9 @@ ULONG Difference::apply(ULONG diffLength, ULONG outLength, UCHAR* const output)
526526
BUGCHECK(176); // msg 176 bad difference record
527527

528528
auto differences = m_differences;
529-
const auto end = differences + diffLength;
529+
const auto* const end = differences + diffLength;
530530
auto p = output;
531-
const auto p_end = output + outLength;
531+
const auto* const p_end = output + outLength;
532532

533533
while (differences < end && p < p_end)
534534
{
@@ -566,15 +566,15 @@ ULONG Difference::apply(ULONG diffLength, ULONG outLength, UCHAR* const output)
566566
return length;
567567
}
568568

569-
ULONG Difference::makeNoDiff(ULONG length)
569+
ULONG Difference::makeNoDiff(ULONG length) noexcept
570570
{
571571
/**************************************
572572
*
573573
* Generates differences record marking that there are no differences.
574574
*
575575
**************************************/
576576
auto output = m_differences;
577-
const auto end = output + MAX_DIFFERENCES;
577+
const auto* const end = output + MAX_DIFFERENCES;
578578

579579
while (length)
580580
{
@@ -593,7 +593,7 @@ ULONG Difference::makeNoDiff(ULONG length)
593593
}
594594

595595
ULONG Difference::make(ULONG length1, const UCHAR* rec1,
596-
ULONG length2, const UCHAR* rec2)
596+
ULONG length2, const UCHAR* rec2) noexcept
597597
{
598598
/**************************************
599599
*
@@ -611,7 +611,7 @@ ULONG Difference::make(ULONG length1, const UCHAR* rec1,
611611
*
612612
**************************************/
613613
auto output = m_differences;
614-
const auto end = output + MAX_DIFFERENCES;
614+
const auto* const end = output + MAX_DIFFERENCES;
615615
const auto end1 = rec1 + MIN(length1, length2);
616616
const auto end2 = rec2 + length2;
617617

@@ -621,7 +621,7 @@ ULONG Difference::make(ULONG length1, const UCHAR* rec1,
621621
{
622622
auto p = output++;
623623

624-
const auto yellow = (UCHAR*) MIN((U_IPTR) end1, ((U_IPTR) rec1 + 127)) - 1;
624+
const auto* const yellow = (UCHAR*) MIN((U_IPTR) end1, ((U_IPTR) rec1 + 127)) - 1;
625625
while (rec1 <= yellow && (rec1[0] != rec2[0] || (rec1 < yellow && rec1[1] != rec2[1])))
626626
{
627627
if (output >= end)
@@ -654,7 +654,7 @@ ULONG Difference::make(ULONG length1, const UCHAR* rec1,
654654
{
655655
auto p = output++;
656656

657-
const auto yellow = (UCHAR*) MIN((U_IPTR) end2, ((U_IPTR) rec2 + 127));
657+
const auto* const yellow = (UCHAR*) MIN((U_IPTR) end2, ((U_IPTR) rec2 + 127));
658658
while (rec2 < yellow)
659659
{
660660
if (output >= end)

src/jrd/sqz.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ namespace Jrd
3737
Compressor(thread_db* tdbb, ULONG length, const UCHAR* data);
3838
Compressor(MemoryPool& pool, bool allowLongRuns, bool allowUnpacked, ULONG length, const UCHAR* data);
3939

40-
ULONG getPackedLength() const
40+
ULONG getPackedLength() const noexcept
4141
{
4242
return m_length;
4343
}
4444

45-
bool isPacked() const
45+
bool isPacked() const noexcept
4646
{
4747
return m_runs.hasData();
4848
}
@@ -69,28 +69,28 @@ namespace Jrd
6969
class Difference
7070
{
7171
// Max length of generated differences string between two records
72-
static const unsigned MAX_DIFFERENCES = 1024;
72+
static constexpr unsigned MAX_DIFFERENCES = 1024;
7373

7474
public:
75-
UCHAR* getData()
75+
UCHAR* getData() noexcept
7676
{
7777
return m_differences;
7878
}
7979

80-
const UCHAR* getData() const
80+
const UCHAR* getData() const noexcept
8181
{
8282
return m_differences;
8383
}
8484

85-
ULONG getCapacity() const
85+
ULONG getCapacity() const noexcept
8686
{
8787
return MAX_DIFFERENCES;
8888
}
8989

9090
ULONG apply(ULONG diffLength, ULONG outLength, UCHAR* output);
9191
ULONG make(ULONG length1, const UCHAR* rec1,
92-
ULONG length2, const UCHAR* rec2);
93-
ULONG makeNoDiff(ULONG length);
92+
ULONG length2, const UCHAR* rec2) noexcept;
93+
ULONG makeNoDiff(ULONG length) noexcept;
9494

9595
private:
9696
UCHAR m_differences[MAX_DIFFERENCES];

0 commit comments

Comments
 (0)