From 9a388740e9523cb4e4f800f03a37194cc7b025d3 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: Sat, 29 Jan 2022 21:56:55 +0100
Subject: [PATCH] tidy: formatting

---
 .../stringology/exact/SequentialSampling.h    | 14 +++---
 .../src/stringology/exact/TailedSubstring.h   | 43 +++++++++----------
 2 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/alib2algo/src/stringology/exact/SequentialSampling.h b/alib2algo/src/stringology/exact/SequentialSampling.h
index 776d595772..fa9dd5f91c 100644
--- a/alib2algo/src/stringology/exact/SequentialSampling.h
+++ b/alib2algo/src/stringology/exact/SequentialSampling.h
@@ -8,10 +8,7 @@
 #include <string/properties/PeriodicPrefix.h>
 #include <string/LinearString.h>
 
-
-namespace stringology {
-
-namespace exact {
+namespace stringology::exact {
 
 namespace {
 
@@ -180,13 +177,12 @@ ext::set < unsigned > SequentialSampling::match ( const string::LinearString < S
 		res = SimpleTextSearching( subject , pattern);
 	} else if ( static_cast < size_t > ( periodic_prefix ) < pattern.getContent().size() ) {
 		res = SeqSampling( subject, pattern , periodic_prefix - period, periodic_prefix );
-	} else res = Mix( subject, pattern, period );
+	} else {
+		res = Mix( subject, pattern, period );
+	}
 
 	measurements::end();
 	return res;
 }
 
-} /* namespace exact */
-
-} /* namespace stringology */
-
+} /* namespace stringology::exact */
diff --git a/alib2algo/src/stringology/exact/TailedSubstring.h b/alib2algo/src/stringology/exact/TailedSubstring.h
index 672ede8166..062e3617ef 100644
--- a/alib2algo/src/stringology/exact/TailedSubstring.h
+++ b/alib2algo/src/stringology/exact/TailedSubstring.h
@@ -7,11 +7,7 @@
 
 #include <string/LinearString.h>
 
-
-namespace stringology {
-
-namespace exact {
-
+namespace stringology::exact {
 
 /**
 * Implementation of the TailedSubstring algorithm from article “ IT’S ECONOMY, STUPID! ” : SEARCHING FOR A SUBSTRING
@@ -26,12 +22,11 @@ public:
 	 */
 	template < class SymbolType >
 	static ext::set < unsigned > match ( const string::LinearString < SymbolType > & subject, const string::LinearString < SymbolType > & pattern );
-
 };
 
 template < class SymbolType >
 ext::set < unsigned > TailedSubstring::match ( const string::LinearString < SymbolType > & subject, const string::LinearString < SymbolType > & pattern ) {
-	ext::set<unsigned> occ;
+	ext::set < unsigned > occ;
 	const auto & text = subject.getContent();
 	const auto & pat = pattern.getContent();
 	long int n = text.size();
@@ -45,14 +40,18 @@ ext::set < unsigned > TailedSubstring::match ( const string::LinearString < Symb
 	measurements::start ( "Algorithm", measurements::Type::ALGORITHM );
 	// Phase 1
 	while ( s <= n - m && i - delta >= 0 ) {
-		if ( pat[i] != text[s + i] ) s = s + 1;
-		else {
+		if ( pat[i] != text[s + i] ) {
+			s = s + 1;
+		} else {
 			long int j = 0;
-			while ( j < m && pat[j] == text[s + j] ) ++j;
-			if ( j == m ) occ.insert(s);
+			while ( j < m && pat[j] == text[s + j] )
+				++j;
+			if ( j == m )
+				occ.insert(s);
 			long int h = i - 1;
-			while ( h >= 0 && pat[h] != pat[i] ) --h;
-			if ( delta < i - h ){
+			while ( h >= 0 && pat[h] != pat[i] )
+				--h;
+			if ( delta < i - h ) {
 				delta = i - h;
 				k = i;
 			}
@@ -63,20 +62,20 @@ ext::set < unsigned > TailedSubstring::match ( const string::LinearString < Symb
 
 	// Phase 2
 	while ( s <= n - m ){
-		if ( pat[k] != text[s+k] ) ++ s;
-		else {
+		if ( pat[k] != text[s+k] ) {
+			++ s;
+		} else {
 			long int j = 0;
-			while ( j < m && pat[j] == text[s+j]) ++j;
-			if ( j == m ) occ.insert(s);
+			while ( j < m && pat[j] == text[s+j])
+				++j;
+			if ( j == m )
+				occ.insert(s);
 			s += delta;
 		}
 	}
+
 	measurements::end();
 	return occ;
 }
 
-
-} /* namespace exact */
-
-} /* namespace stringology */
-
+} /* namespace stringology::exact */
-- 
GitLab