From 4489f120f98281925ea384a0b87a5ff30b003706 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 15 Jul 2017 22:40:38 -0400 Subject: [PATCH] Eliminated foolish double indirection on phase history. --- Storage/Disk/DigitalPhaseLockedLoop.cpp | 12 +++++------- Storage/Disk/DigitalPhaseLockedLoop.hpp | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Storage/Disk/DigitalPhaseLockedLoop.cpp b/Storage/Disk/DigitalPhaseLockedLoop.cpp index c22d17053..231b71e4a 100644 --- a/Storage/Disk/DigitalPhaseLockedLoop.cpp +++ b/Storage/Disk/DigitalPhaseLockedLoop.cpp @@ -17,9 +17,8 @@ DigitalPhaseLockedLoop::DigitalPhaseLockedLoop(int clocks_per_bit, int tolerance tolerance_(tolerance), phase_(0), window_length_(clocks_per_bit), - phase_error_pointer_(0) { - phase_error_history_.reset(new std::vector(length_of_history, 0)); -} + phase_error_pointer_(0), + phase_error_history_(length_of_history, 0) {} void DigitalPhaseLockedLoop::run_for_cycles(int number_of_cycles) { phase_ += number_of_cycles; @@ -51,15 +50,14 @@ void DigitalPhaseLockedLoop::post_phase_error(int error) { phase_ -= (error + 1) >> 1; // use the average of the last few errors to affect frequency - std::vector *phase_error_history = phase_error_history_.get(); - size_t phase_error_history_size = phase_error_history->size(); + size_t phase_error_history_size = phase_error_history_.size(); - (*phase_error_history)[phase_error_pointer_] = error; + phase_error_history_[phase_error_pointer_] = error; phase_error_pointer_ = (phase_error_pointer_ + 1)%phase_error_history_size; int total_error = 0; for(size_t c = 0; c < phase_error_history_size; c++) { - total_error += (*phase_error_history)[c]; + total_error += phase_error_history_[c]; } int denominator = (int)(phase_error_history_size * 4); window_length_ += (total_error + (denominator >> 1)) / denominator; diff --git a/Storage/Disk/DigitalPhaseLockedLoop.hpp b/Storage/Disk/DigitalPhaseLockedLoop.hpp index a1e5dd7a5..d4b38153e 100644 --- a/Storage/Disk/DigitalPhaseLockedLoop.hpp +++ b/Storage/Disk/DigitalPhaseLockedLoop.hpp @@ -52,7 +52,7 @@ class DigitalPhaseLockedLoop { Delegate *delegate_; void post_phase_error(int error); - std::unique_ptr> phase_error_history_; + std::vector phase_error_history_; size_t phase_error_pointer_; int phase_;