From 40516c9cece8a037e09047a8cd548709797162e8 Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Sun, 7 Mar 2021 15:56:58 -0500
Subject: [PATCH] Minor style improvements: some local `const`s, and
 `override`s.

---
 Storage/Tape/Parsers/Acorn.cpp     |  7 ++++---
 Storage/Tape/Parsers/Acorn.hpp     |  6 +++---
 Storage/Tape/Parsers/Commodore.cpp | 13 ++++++-------
 Storage/Tape/Parsers/Commodore.hpp |  4 ++--
 Storage/Tape/Parsers/Oric.cpp      |  2 +-
 Storage/Tape/Parsers/Oric.hpp      |  4 ++--
 Storage/Tape/Parsers/ZX8081.cpp    |  6 +++---
 Storage/Tape/Parsers/ZX8081.hpp    |  7 +++----
 8 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/Storage/Tape/Parsers/Acorn.cpp b/Storage/Tape/Parsers/Acorn.cpp
index 4c8895ec2..65c976adb 100644
--- a/Storage/Tape/Parsers/Acorn.cpp
+++ b/Storage/Tape/Parsers/Acorn.cpp
@@ -24,12 +24,13 @@ int Parser::get_next_bit(const std::shared_ptr<Storage::Tape::Tape> &tape) {
 }
 
 int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) {
-	int value = 0;
-	int c = 8;
 	if(get_next_bit(tape)) {
 		set_error_flag();
 		return -1;
 	}
+
+	int value = 0;
+	int c = 8;
 	while(c--) {
 		value = (value >> 1) | (get_next_bit(tape) << 7);
 	}
@@ -74,7 +75,7 @@ Shifter::Shifter() :
 void Shifter::process_pulse(const Storage::Tape::Tape::Pulse &pulse) {
 	pll_.run_for(Cycles(int(float(PLLClockRate) * pulse.length.get<float>())));
 
-	bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
+	const bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
 	if(is_high != was_high_) {
 		pll_.add_pulse();
 	}
diff --git a/Storage/Tape/Parsers/Acorn.hpp b/Storage/Tape/Parsers/Acorn.hpp
index 5d4673701..394f19bac 100644
--- a/Storage/Tape/Parsers/Acorn.hpp
+++ b/Storage/Tape/Parsers/Acorn.hpp
@@ -57,10 +57,10 @@ class Parser: public Storage::Tape::Parser<SymbolType>, public Shifter::Delegate
 		void reset_crc();
 		uint16_t get_crc();
 
-		void acorn_shifter_output_bit(int value);
-		void process_pulse(const Storage::Tape::Tape::Pulse &pulse);
-
 	private:
+		void acorn_shifter_output_bit(int value) override;
+		void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
+
 		bool did_update_shifter(int new_value, int length);
 		CRC::Generator<uint16_t, 0x0000, 0x0000, false, false> crc_;
 		Shifter shifter_;
diff --git a/Storage/Tape/Parsers/Commodore.cpp b/Storage/Tape/Parsers/Commodore.cpp
index a8a15d3bd..7e33c1596 100644
--- a/Storage/Tape/Parsers/Commodore.cpp
+++ b/Storage/Tape/Parsers/Commodore.cpp
@@ -76,7 +76,7 @@ std::unique_ptr<Header> Parser::get_next_header_body(const std::shared_ptr<Stora
 	reset_parity_byte();
 
 	// get header type
-	uint8_t header_type = get_next_byte(tape);
+	const uint8_t header_type = get_next_byte(tape);
 	switch(header_type) {
 		default:	header->type = Header::Unknown;					break;
 		case 0x01:	header->type = Header::RelocatableProgram;		break;
@@ -92,7 +92,7 @@ std::unique_ptr<Header> Parser::get_next_header_body(const std::shared_ptr<Stora
 		header->data.push_back(get_next_byte(tape));
 	}
 
-	uint8_t parity_byte = get_parity_byte();
+	const uint8_t parity_byte = get_parity_byte();
 	header->parity_was_valid = get_next_byte(tape) == parity_byte;
 
 	// parse if this is not pure data
@@ -110,7 +110,7 @@ std::unique_ptr<Header> Parser::get_next_header_body(const std::shared_ptr<Stora
 	return header;
 }
 
-void Header::serialise(uint8_t *target, uint16_t length) {
+void Header::serialise(uint8_t *target, [[maybe_unused]] uint16_t length) {
 	switch(type) {
 		default:							target[0] = 0xff;	break;
 		case Header::RelocatableProgram:	target[0] = 0x01;	break;
@@ -121,7 +121,6 @@ void Header::serialise(uint8_t *target, uint16_t length) {
 	}
 
 	// TODO: validate length.
-	(void)length;
 
 	std::memcpy(&target[1], data.data(), 191);
 }
@@ -178,7 +177,7 @@ void Parser::proceed_to_landing_zone(const std::shared_ptr<Storage::Tape::Tape>
 */
 void Parser::proceed_to_symbol(const std::shared_ptr<Storage::Tape::Tape> &tape, SymbolType required_symbol) {
 	while(!tape->is_at_end()) {
-		SymbolType symbol = get_next_symbol(tape);
+		const SymbolType symbol = get_next_symbol(tape);
 		if(symbol == required_symbol) return;
 	}
 }
@@ -187,7 +186,7 @@ void Parser::proceed_to_symbol(const std::shared_ptr<Storage::Tape::Tape> &tape,
 	Swallows the next byte; sets the error flag if it is not equal to @c value.
 */
 void Parser::expect_byte(const std::shared_ptr<Storage::Tape::Tape> &tape, uint8_t value) {
-	uint8_t next_byte = get_next_byte(tape);
+	const uint8_t next_byte = get_next_byte(tape);
 	if(next_byte != value) set_error_flag();
 }
 
@@ -247,7 +246,7 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) {
 	// short: 182us		=>	0.000364s cycle
 	// medium: 262us	=>	0.000524s cycle
 	// long: 342us		=>	0.000684s cycle
-	bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
+	const bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
 	if(!is_high && previous_was_high_) {
 		if(wave_period_ >= 0.000764)		push_wave(WaveType::Unrecognised);
 		else if(wave_period_ >= 0.000604)	push_wave(WaveType::Long);
diff --git a/Storage/Tape/Parsers/Commodore.hpp b/Storage/Tape/Parsers/Commodore.hpp
index 0a64728f4..b7cc8aecb 100644
--- a/Storage/Tape/Parsers/Commodore.hpp
+++ b/Storage/Tape/Parsers/Commodore.hpp
@@ -126,7 +126,7 @@ class Parser: public Storage::Tape::PulseClassificationParser<WaveType, SymbolTy
 			indicates a high to low transition, inspects the time since the last transition, to produce
 			a long, medium, short or unrecognised wave period.
 		*/
-		void process_pulse(const Storage::Tape::Tape::Pulse &pulse);
+		void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
 		bool previous_was_high_ = false;
 		float wave_period_ = 0.0f;
 
@@ -134,7 +134,7 @@ class Parser: public Storage::Tape::PulseClassificationParser<WaveType, SymbolTy
 			Per the contract with Analyser::Static::TapeParser; produces any of a word marker, an end-of-block marker,
 			a zero, a one or a lead-in symbol based on the currently captured waves.
 		*/
-		void inspect_waves(const std::vector<WaveType> &waves);
+		void inspect_waves(const std::vector<WaveType> &waves) override;
 };
 
 }
diff --git a/Storage/Tape/Parsers/Oric.cpp b/Storage/Tape/Parsers/Oric.cpp
index ffb98cab2..cc3019bc4 100644
--- a/Storage/Tape/Parsers/Oric.cpp
+++ b/Storage/Tape/Parsers/Oric.cpp
@@ -45,7 +45,7 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) {
 	constexpr float maximum_medium_length = 0.000728f;
 	constexpr float maximum_long_length = 0.001456f;
 
-	bool wave_is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
+	const bool wave_is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
 	if(!wave_was_high_ && wave_is_high != wave_was_high_) {
 		if(cycle_length_ < maximum_short_length) push_wave(WaveType::Short);
 		else if(cycle_length_ < maximum_medium_length) push_wave(WaveType::Medium);
diff --git a/Storage/Tape/Parsers/Oric.hpp b/Storage/Tape/Parsers/Oric.hpp
index 0b46541e9..4a5f2d403 100644
--- a/Storage/Tape/Parsers/Oric.hpp
+++ b/Storage/Tape/Parsers/Oric.hpp
@@ -32,8 +32,8 @@ class Parser: public Storage::Tape::PulseClassificationParser<WaveType, SymbolTy
 		bool sync_and_get_encoding_speed(const std::shared_ptr<Storage::Tape::Tape> &tape);
 
 	private:
-		void process_pulse(const Storage::Tape::Tape::Pulse &pulse);
-		void inspect_waves(const std::vector<WaveType> &waves);
+		void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
+		void inspect_waves(const std::vector<WaveType> &waves) override;
 
 		enum DetectionMode {
 			FastData,
diff --git a/Storage/Tape/Parsers/ZX8081.cpp b/Storage/Tape/Parsers/ZX8081.cpp
index 1e11502b5..487c6a398 100644
--- a/Storage/Tape/Parsers/ZX8081.cpp
+++ b/Storage/Tape/Parsers/ZX8081.cpp
@@ -15,8 +15,8 @@ Parser::Parser() : pulse_was_high_(false), pulse_time_(0) {}
 void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) {
 	// If this is anything other than a transition from low to high, just add it to the
 	// count of time.
-	bool pulse_is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
-	bool pulse_did_change = pulse_is_high != pulse_was_high_;
+	const bool pulse_is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
+	const bool pulse_did_change = pulse_is_high != pulse_was_high_;
 	pulse_was_high_ = pulse_is_high;
 	if(!pulse_did_change || !pulse_is_high) {
 		pulse_time_ += pulse.length;
@@ -31,7 +31,7 @@ void Parser::process_pulse(const Storage::Tape::Tape::Pulse &pulse) {
 void Parser::post_pulse() {
 	constexpr float expected_pulse_length = 300.0f / 1000000.0f;
 	constexpr float expected_gap_length = 1300.0f / 1000000.0f;
-	auto pulse_time = pulse_time_.get<float>();
+	const auto pulse_time = pulse_time_.get<float>();
 
 	if(pulse_time > expected_gap_length * 1.25f) {
 		push_wave(WaveType::LongGap);
diff --git a/Storage/Tape/Parsers/ZX8081.hpp b/Storage/Tape/Parsers/ZX8081.hpp
index bb32f7cdd..a3f3b8de7 100644
--- a/Storage/Tape/Parsers/ZX8081.hpp
+++ b/Storage/Tape/Parsers/ZX8081.hpp
@@ -50,10 +50,9 @@ class Parser: public Storage::Tape::PulseClassificationParser<WaveType, SymbolTy
 		Time pulse_time_;
 		void post_pulse();
 
-		void process_pulse(const Storage::Tape::Tape::Pulse &pulse);
-		void mark_end();
-
-		void inspect_waves(const std::vector<WaveType> &waves);
+		void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
+		void mark_end() override;
+		void inspect_waves(const std::vector<WaveType> &waves) override;
 
 		std::shared_ptr<std::vector<uint8_t>> get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape);
 };