From 03b30993a538167b39cde6ee749f1642d54effd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Tr=C3=A1vn=C3=AD=C4=8Dek?= <jan.travnicek@fit.cvut.cz> Date: Sun, 30 Jan 2022 00:10:39 +0100 Subject: [PATCH] algo: drop not needed use of ssize_t --- alib2algo/src/string/properties/PeriodicPrefix.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/alib2algo/src/string/properties/PeriodicPrefix.h b/alib2algo/src/string/properties/PeriodicPrefix.h index c1612c95ea..85d252dc31 100644 --- a/alib2algo/src/string/properties/PeriodicPrefix.h +++ b/alib2algo/src/string/properties/PeriodicPrefix.h @@ -22,9 +22,9 @@ public: }; namespace { - // return period if pattern is periodic, else -1 + // return period if pattern is periodic, else length of x template <class SymbolType> - ssize_t hasShortPeriod ( const ext::vector<SymbolType>& x , size_t prefixLen ) { + size_t hasShortPeriod ( const ext::vector<SymbolType>& x , size_t prefixLen ) { for ( size_t per = 1 ; per <= prefixLen/2 ; ++ per ){ bool hasPer = true ; for ( size_t i = per ; i < prefixLen ; ++ i ) { @@ -32,7 +32,7 @@ namespace { } if ( hasPer ) return per ; } - return -1 ; + return x.size ( ) ; } } @@ -43,7 +43,7 @@ ext::pair<ssize_t, ssize_t > PeriodicPrefix::construct(const string::LinearStrin ssize_t maxlen = -1 , maxper = -1 ; for ( size_t i = 1 ; i <= x.size() ; ++ i ) { auto per = hasShortPeriod(x , i) ; - if ( per != -1 ) { + if ( per != x.size ( ) ) { maxlen = i ; maxper = per ; } -- GitLab