From f804c32eeeb6058f8cad2239620722595b7f05e6 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 3 Dec 2024 22:57:38 -0500 Subject: [PATCH] Opportunistically `const`. --- Storage/Tape/Formats/CSW.cpp | 6 +++--- Storage/Tape/Formats/TZX.cpp | 21 +++++++++++++-------- Storage/Tape/Formats/TapeUEF.cpp | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Storage/Tape/Formats/CSW.cpp b/Storage/Tape/Formats/CSW.cpp index 12b90e6dd..8263aa39e 100644 --- a/Storage/Tape/Formats/CSW.cpp +++ b/Storage/Tape/Formats/CSW.cpp @@ -94,9 +94,9 @@ CSW::Serialiser::Serialiser(const std::string &file_name) : source_data_pointer_ CSW::Serialiser::Serialiser( const std::vector &&data, - CompressionType compression_type, - bool initial_level, - uint32_t sampling_rate + const CompressionType compression_type, + const bool initial_level, + const uint32_t sampling_rate ) : compression_type_(compression_type) { pulse_.length.clock_rate = sampling_rate; pulse_.type = initial_level ? Pulse::High : Pulse::Low; diff --git a/Storage/Tape/Formats/TZX.cpp b/Storage/Tape/Formats/TZX.cpp index 03ee816cb..8f108afce 100644 --- a/Storage/Tape/Formats/TZX.cpp +++ b/Storage/Tape/Formats/TZX.cpp @@ -113,7 +113,12 @@ void TZX::Serialiser::get_csw_recording_block() { std::vector raw_block = file_.read(block_length - 10); - CSW csw(std::move(raw_block), (compression_type == 2) ? CSW::CompressionType::ZRLE : CSW::CompressionType::RLE, current_level_, sampling_rate); + CSW csw( + std::move(raw_block), + (compression_type == 2) ? CSW::CompressionType::ZRLE : CSW::CompressionType::RLE, + current_level_, + sampling_rate + ); while(!csw.is_at_end()) { Pulse next_pulse = csw.next_pulse(); current_level_ = (next_pulse.type == Pulse::High); @@ -146,10 +151,10 @@ void TZX::Serialiser::get_generalised_data_block() { } void TZX::Serialiser::get_generalised_segment( - uint32_t output_symbols, - uint8_t max_pulses_per_symbol, - uint8_t number_of_symbols, - bool is_data + const uint32_t output_symbols, + const uint8_t max_pulses_per_symbol, + const uint8_t number_of_symbols, + const bool is_data ) { if(!output_symbols) return; @@ -402,15 +407,15 @@ void TZX::Serialiser::get_kansas_city_block() { // MARK: - Output -void TZX::Serialiser::post_pulses(unsigned int count, unsigned int length) { +void TZX::Serialiser::post_pulses(unsigned int count, const unsigned int length) { while(count--) post_pulse(length); } -void TZX::Serialiser::post_pulse(unsigned int length) { +void TZX::Serialiser::post_pulse(const unsigned int length) { post_pulse(Storage::Time(length, StandardTZXClock)); } -void TZX::Serialiser::post_gap(unsigned int milliseconds) { +void TZX::Serialiser::post_gap(const unsigned int milliseconds) { if(!milliseconds) return; if(milliseconds > 1 && !current_level_) { post_pulse(Storage::Time(TZXClockMSMultiplier, StandardTZXClock)); diff --git a/Storage/Tape/Formats/TapeUEF.cpp b/Storage/Tape/Formats/TapeUEF.cpp index 97ce557a7..34be96dca 100644 --- a/Storage/Tape/Formats/TapeUEF.cpp +++ b/Storage/Tape/Formats/TapeUEF.cpp @@ -178,7 +178,7 @@ void UEF::Serialiser::queue_implicit_bit_pattern(uint32_t length) { } } -void UEF::Serialiser::queue_explicit_bit_pattern(uint32_t length) { +void UEF::Serialiser::queue_explicit_bit_pattern(const uint32_t length) { const std::size_t length_in_bits = (length << 3) - size_t(gzget8(file_)); uint8_t current_byte = 0; for(std::size_t bit = 0; bit < length_in_bits; bit++) { @@ -298,7 +298,7 @@ void UEF::Serialiser::queue_implicit_byte(uint8_t byte) { queue_bit(1); } -void UEF::Serialiser::queue_bit(int bit) { +void UEF::Serialiser::queue_bit(const int bit) { int number_of_cycles; Time duration; duration.clock_rate = time_base_ * 4;