From 3f3a9a156736d4da0339b3c2d9b042f4ed7c7fb2 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 3 Feb 2023 19:01:04 +0100 Subject: Refactor, removed a redundant function --- Examples/WhisperDesktop/Utils/logger.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'Examples/WhisperDesktop/Utils/logger.cpp') diff --git a/Examples/WhisperDesktop/Utils/logger.cpp b/Examples/WhisperDesktop/Utils/logger.cpp index 5c7c257..712835b 100644 --- a/Examples/WhisperDesktop/Utils/logger.cpp +++ b/Examples/WhisperDesktop/Utils/logger.cpp @@ -24,14 +24,17 @@ namespace } } -void printTimeStamp( CStringA& rdi, Whisper::sTimeSpan ts ) +void printTime( CStringA& rdi, Whisper::sTimeSpan time, bool comma ) { - sTimeSpanFields fields = ts; - uint32_t msec = fields.ticks / 10'000; - uint32_t hr = fields.days * 24 + fields.hours; - uint32_t min = fields.minutes; - uint32_t sec = fields.seconds; - rdi.AppendFormat( "%02d:%02d:%02d.%03d", hr, min, sec, msec ); + Whisper::sTimeSpanFields fields = time; + const uint32_t hours = fields.days * 24 + fields.hours; + const char separator = comma ? ',' : '.'; + rdi.AppendFormat( "%02d:%02d:%02d%c%03d", + (int)hours, + (int)fields.minutes, + (int)fields.seconds, + separator, + fields.ticks / 10'000 ); } HRESULT logNewSegments( const iTranscribeResult* results, size_t newSegments, bool printSpecial ) @@ -50,9 +53,9 @@ HRESULT logNewSegments( const iTranscribeResult* results, size_t newSegments, bo { const sSegment& seg = segments[ i ]; str = "["; - printTimeStamp( str, seg.time.begin ); + printTime( str, seg.time.begin ); str += " --> "; - printTimeStamp( str, seg.time.end ); + printTime( str, seg.time.end ); str += "] "; for( uint32_t j = 0; j < seg.countTokens; j++ ) -- cgit v1.2.3