Skip to content

Commit 7550a00

Browse files
andiwandclaude
andauthored
PDF: const-qualify scalar by-value constructor params (#576)
* PDF: const-qualify scalar by-value constructor params Add top-level const to the cheap scalar by-value parameters `n` (ExponentialFunction) and `bits_per_sample` (SampledFunction), matching the codebase convention of const-qualifying scalar params in definitions. Object/vector params stay non-const because they are std::move'd into members, so adding const would defeat the move. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 39cf457 commit 7550a00

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/odr/internal/pdf/pdf_document_element.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class CodeRange {
209209
using reference = std::uint32_t;
210210

211211
Iterator() = default;
212-
Iterator(const char *position, std::size_t width)
212+
Iterator(const char *position, const std::size_t width)
213213
: m_position{position}, m_width{width} {}
214214

215215
std::uint32_t operator*() const {
@@ -239,7 +239,7 @@ class CodeRange {
239239
std::size_t m_width{1};
240240
};
241241

242-
CodeRange(std::string_view codes, std::size_t width)
242+
CodeRange(const std::string_view codes, const std::size_t width)
243243
: m_codes{codes}, m_width{width} {}
244244

245245
// `data()` is used as a bounded byte range delimited by `end()`, not as a

src/odr/internal/pdf/pdf_function.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ double interpolate(const double x, const double a0, const double a1,
4646
class ExponentialFunction final : public Function {
4747
public:
4848
ExponentialFunction(std::vector<double> domain, std::vector<double> range,
49-
std::vector<double> c0, std::vector<double> c1, double n)
49+
std::vector<double> c0, std::vector<double> c1,
50+
const double n)
5051
: Function(std::move(domain), std::move(range)), m_c0{std::move(c0)},
5152
m_c1{std::move(c1)}, m_n{n} {}
5253

@@ -115,7 +116,8 @@ class StitchingFunction final : public Function {
115116
class SampledFunction final : public Function {
116117
public:
117118
SampledFunction(std::vector<double> domain, std::vector<double> range,
118-
std::vector<std::size_t> size, std::int32_t bits_per_sample,
119+
std::vector<std::size_t> size,
120+
const std::int32_t bits_per_sample,
119121
std::vector<double> encode, std::vector<double> decode,
120122
std::string samples)
121123
: Function(std::move(domain), std::move(range)), m_size{std::move(size)},

0 commit comments

Comments
 (0)