From 00a87c6f5ff61800ffb1cf6bba036e74776dde13 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Tue, 13 Aug 2024 23:33:11 +0300 Subject: [PATCH] refactor: added const reference function params if size > 16 --- src/logdata/include/linetypes.h | 2 +- src/logdata/include/logdataworker.h | 2 +- src/logdata/include/logfiltereddataworker.h | 2 +- src/logdata/src/logdataworker.cpp | 2 +- src/logdata/src/logfiltereddataworker.cpp | 2 +- src/ui/include/abstractlogview.h | 6 +++--- src/ui/include/crawlerwidget.h | 8 ++++---- src/ui/include/mainwindow.h | 4 ++-- src/ui/include/quickfind.h | 6 +++--- src/ui/include/quickfindpattern.h | 4 ++-- src/ui/include/selection.h | 4 ++-- src/ui/src/abstractlogview.cpp | 6 +++--- src/ui/src/crawlerwidget.cpp | 4 ++-- src/ui/src/mainwindow.cpp | 4 ++-- src/ui/src/quickfind.cpp | 6 +++--- src/ui/src/quickfindpattern.cpp | 4 ++-- src/ui/src/selection.cpp | 6 +++--- src/utils/include/crc32.h | 4 ++-- src/versioncheck/include/versionchecker.h | 2 +- src/versioncheck/src/versionchecker.cpp | 4 ++-- 20 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/logdata/include/linetypes.h b/src/logdata/include/linetypes.h index c8689d688..70d6c230a 100644 --- a/src/logdata/include/linetypes.h +++ b/src/logdata/include/linetypes.h @@ -306,7 +306,7 @@ class FilePosition { // Length of a tab stop constexpr int TabStop = 8; -inline QString untabify( QString&& line, LineColumn initialPosition = 0_lcol ) +inline QString untabify( QString&& line, const LineColumn& initialPosition = 0_lcol ) { line.replace( QChar::Null, QChar::Space ); diff --git a/src/logdata/include/logdataworker.h b/src/logdata/include/logdataworker.h index 3e53a7b1f..7f11b93f7 100644 --- a/src/logdata/include/logdataworker.h +++ b/src/logdata/include/logdataworker.h @@ -209,7 +209,7 @@ class IndexingData { // Atomically add to all the existing // indexing data. - void addAll( const klogg::vector& block, LineLength length, + void addAll( const klogg::vector& block, const LineLength& length, const FastLinePositionArray& linePosition, QTextCodec* encoding ); // Completely clear the indexing data. diff --git a/src/logdata/include/logfiltereddataworker.h b/src/logdata/include/logfiltereddataworker.h index 0163ebaa0..81bbfaf40 100644 --- a/src/logdata/include/logfiltereddataworker.h +++ b/src/logdata/include/logfiltereddataworker.h @@ -100,7 +100,7 @@ class SearchData { SearchResults takeCurrentResults() const; // Atomically add to all the existing search data. - void addAll( LineLength length, const SearchResultArray& matches, LinesCount nbLinesProcessed ); + void addAll( const LineLength& length, const SearchResultArray& matches, LinesCount nbLinesProcessed ); // Get the number of matches LinesCount getNbMatches() const; // Get the last matched line number diff --git a/src/logdata/src/logdataworker.cpp b/src/logdata/src/logdataworker.cpp index beed2a4ff..0f0f9a43a 100644 --- a/src/logdata/src/logdataworker.cpp +++ b/src/logdata/src/logdataworker.cpp @@ -111,7 +111,7 @@ QTextCodec* IndexingData::getForcedEncoding() const return encodingForced_; } -void IndexingData::addAll( const klogg::vector& block, LineLength length, +void IndexingData::addAll( const klogg::vector& block, const LineLength& length, const FastLinePositionArray& linePosition, QTextCodec* encoding ) { diff --git a/src/logdata/src/logfiltereddataworker.cpp b/src/logdata/src/logfiltereddataworker.cpp index a0c80ebe2..8e4e0fb62 100644 --- a/src/logdata/src/logfiltereddataworker.cpp +++ b/src/logdata/src/logfiltereddataworker.cpp @@ -129,7 +129,7 @@ SearchResults SearchData::takeCurrentResults() const return SearchResults{ std::exchange( newMatches_, {} ), maxLength_, nbLinesProcessed_ }; } -void SearchData::addAll( LineLength length, const SearchResultArray& matches, LinesCount lines ) +void SearchData::addAll( const LineLength& length, const SearchResultArray& matches, LinesCount lines ) { UniqueLock lock( dataMutex_ ); diff --git a/src/ui/include/abstractlogview.h b/src/ui/include/abstractlogview.h index 97ee9b4d8..5e3211c46 100644 --- a/src/ui/include/abstractlogview.h +++ b/src/ui/include/abstractlogview.h @@ -245,8 +245,8 @@ class AbstractLogView : public QAbstractScrollArea, public SearchableWidgetInter // Scrolling as necessary void trySelectLine( LineNumber newLine ); void selectAndDisplayLine( LineNumber line ); - void selectPortionAndDisplayLine( LineNumber line, LinesCount nLines, LineColumn startCol, - LineLength nSymbols ); + void selectPortionAndDisplayLine( LineNumber line, LinesCount nLines, const LineColumn& startCol, + const LineLength& nSymbols ); // Use the current QFP to go and select the next match. void searchForward() override; @@ -480,7 +480,7 @@ class AbstractLogView : public QAbstractScrollArea, public SearchableWidgetInter // Utils functions void updateGlobalSelection(); - void selectAndDisplayRange( FilePosition pos ); + void selectAndDisplayRange( const FilePosition& pos ); }; #endif diff --git a/src/ui/include/crawlerwidget.h b/src/ui/include/crawlerwidget.h index 7fe1a4dd6..bc44bbacf 100644 --- a/src/ui/include/crawlerwidget.h +++ b/src/ui/include/crawlerwidget.h @@ -198,11 +198,11 @@ class CrawlerWidget : public QSplitter, void updateFilteredView( LinesCount nbMatches, int progress, LineNumber initialPosition ); // Called when a new line has been selected in the filtered view, // to instruct the main view to jump to the matching line. - void jumpToMatchingLine( LineNumber filteredLineNb, LinesCount nLines, LineColumn startCol, - LineLength nSymbols ); + void jumpToMatchingLine( LineNumber filteredLineNb, LinesCount nLines, const LineColumn& startCol, + const LineLength& nSymbols ); // Called when the main view is on a new line number - void updateLineNumberHandler( LineNumber line, LinesCount nLines, LineColumn startCol, - LineLength nSymbols ); + void updateLineNumberHandler( LineNumber line, LinesCount nLines, const LineColumn& startCol, + const LineLength& nSymbols ); // Mark a line that has been clicked on the main (top) view. void markLinesFromMain( const klogg::vector& lines ); // Mark a line that has been clicked on the filtered (bottom) view. diff --git a/src/ui/include/mainwindow.h b/src/ui/include/mainwindow.h index 5ef9f2282..229899883 100644 --- a/src/ui/include/mainwindow.h +++ b/src/ui/include/mainwindow.h @@ -146,8 +146,8 @@ class MainWindow : public QMainWindow { // Update the selection information displayed in the status bar. // Must be passed as the internal (starts at 0) line number. - void lineNumberHandler( LineNumber startLine, LinesCount nLines, LineColumn startCol, - LineLength nSymbols ); + void lineNumberHandler( LineNumber startLine, LinesCount nLines, const LineColumn& startCol, + const LineLength& nSymbols ); // Save current search in line edit as predefined filter. // Opens dialog with new entry. diff --git a/src/ui/include/quickfind.h b/src/ui/include/quickfind.h index 57a8af566..94e5ac3f9 100644 --- a/src/ui/include/quickfind.h +++ b/src/ui/include/quickfind.h @@ -152,7 +152,7 @@ class QuickFind : public QObject { class LastMatchPosition { public: - void set( LineNumber line, LineColumn column ); + void set( LineNumber line, const LineColumn& column ); void set( const FilePosition& position ); void reset() { @@ -160,10 +160,10 @@ class QuickFind : public QObject { column_ = LineColumn{-1}; } // Does the passed position come after the recorded one - bool isLater( OptionalLineNumber line, LineColumn column ) const; + bool isLater( OptionalLineNumber line, const LineColumn& column ) const; bool isLater( const FilePosition& position ) const; // Does the passed position come before the recorded one - bool isSooner( OptionalLineNumber line, LineColumn column ) const; + bool isSooner( OptionalLineNumber line, const LineColumn& column ) const; bool isSooner( const FilePosition& position ) const; private: diff --git a/src/ui/include/quickfindpattern.h b/src/ui/include/quickfindpattern.h index e26d3dc0f..8a3bff263 100644 --- a/src/ui/include/quickfindpattern.h +++ b/src/ui/include/quickfindpattern.h @@ -69,10 +69,10 @@ class QuickFindMatcher { // Returns whether there is a match in the passed line, starting at // the passed column. // Results are stored internally. - bool isLineMatching( const QString& line, LineColumn column = 0_lcol ) const; + bool isLineMatching( const QString& line, const LineColumn& column = 0_lcol ) const; // Same as isLineMatching but search backward - bool isLineMatchingBackward( const QString& line, LineColumn column = LineColumn{-1} ) const; + bool isLineMatchingBackward( const QString& line, const LineColumn& column = LineColumn{-1} ) const; // Must be called when isLineMatching returns 'true', returns // the position of the first match found. diff --git a/src/ui/include/selection.h b/src/ui/include/selection.h index fddd43e8f..36acd10ae 100644 --- a/src/ui/include/selection.h +++ b/src/ui/include/selection.h @@ -94,7 +94,7 @@ class Selection { selectedLine_ = line; } // Select a portion of line (both start and end included) - void selectPortion( LineNumber line, LineColumn startColumn, LineColumn endColumn ); + void selectPortion( LineNumber line, const LineColumn& startColumn, const LineColumn& endColumn ); void selectPortion( const Portion& selection ) { selectPortion( selection.line(), selection.startColumn(), selection.endColumn() ); @@ -145,7 +145,7 @@ class Selection { bool isLineSelected( LineNumber line ) const; // Returns wether the line passed is selected in certain range. - bool isPortionSelected( LineNumber line, LineColumn startColumn, LineColumn endColumn ) const; + bool isPortionSelected( LineNumber line, const LineColumn& startColumn, const LineColumn& endColumn ) const; // Returns the line selected or -1 if not a single line selection OptionalLineNumber selectedLine() const; diff --git a/src/ui/src/abstractlogview.cpp b/src/ui/src/abstractlogview.cpp index e4694a776..12c7d22ab 100644 --- a/src/ui/src/abstractlogview.cpp +++ b/src/ui/src/abstractlogview.cpp @@ -254,7 +254,7 @@ class WrappedLinesView { return wrappedLines_.size(); } - klogg::vector mid( LineColumn start, LineLength length ) const + klogg::vector mid( const LineColumn& start, const LineLength& length ) const { auto getLength = []( const auto& view ) -> LineLength::UnderlyingType { return type_safe::narrow_cast( view.size() ); @@ -1790,7 +1790,7 @@ void AbstractLogView::selectAndDisplayLine( LineNumber line ) } void AbstractLogView::selectPortionAndDisplayLine( LineNumber line, LinesCount nLines, - LineColumn startCol, LineLength nSymbols ) + const LineColumn& startCol, const LineLength& nSymbols ) { disableFollow(); selection_.selectLine( line ); @@ -2081,7 +2081,7 @@ void AbstractLogView::updateGlobalSelection() } } -void AbstractLogView::selectAndDisplayRange( FilePosition pos ) +void AbstractLogView::selectAndDisplayRange( const FilePosition& pos ) { disableFollow(); selection_.selectRange( selectionStartPos_.line(), pos.line() ); diff --git a/src/ui/src/crawlerwidget.cpp b/src/ui/src/crawlerwidget.cpp index 492f76113..9253351db 100644 --- a/src/ui/src/crawlerwidget.cpp +++ b/src/ui/src/crawlerwidget.cpp @@ -545,7 +545,7 @@ void CrawlerWidget::updateFilteredView( LinesCount nbMatches, int progress, } void CrawlerWidget::jumpToMatchingLine( LineNumber filteredLineNb, LinesCount nLines, - LineColumn startCol, LineLength nSymbols ) + const LineColumn& startCol, const LineLength& nSymbols ) { const auto mainViewLine = logFilteredData_->getMatchingLineNumber( filteredLineNb ); logMainView_->selectPortionAndDisplayLine( mainViewLine, nLines, startCol, @@ -553,7 +553,7 @@ void CrawlerWidget::jumpToMatchingLine( LineNumber filteredLineNb, LinesCount nL } void CrawlerWidget::updateLineNumberHandler( LineNumber line, LinesCount nLines, - LineColumn startCol, LineLength nSymbols ) + const LineColumn& startCol, const LineLength& nSymbols ) { currentLineNumber_ = line; Q_EMIT newSelection( line, nLines, startCol, nSymbols ); diff --git a/src/ui/src/mainwindow.cpp b/src/ui/src/mainwindow.cpp index cd343fe2c..af5e3be1e 100644 --- a/src/ui/src/mainwindow.cpp +++ b/src/ui/src/mainwindow.cpp @@ -1319,8 +1319,8 @@ void MainWindow::changeFollowMode( bool follow ) followAction->setChecked( follow ); } -void MainWindow::lineNumberHandler( LineNumber startLine, LinesCount nLines, LineColumn startCol, - LineLength nSymbols ) +void MainWindow::lineNumberHandler( LineNumber startLine, LinesCount nLines, const LineColumn& startCol, + const LineLength& nSymbols ) { // The line number received is the internal (starts at 0) uint64_t fileSize{}; diff --git a/src/ui/src/quickfind.cpp b/src/ui/src/quickfind.cpp index 0e3beebed..bb4b0f46e 100644 --- a/src/ui/src/quickfind.cpp +++ b/src/ui/src/quickfind.cpp @@ -71,7 +71,7 @@ void SearchingNotifier::sendNotification( LineNumber current_line, LinesCount nb startTime_ = QTime::currentTime().addMSecs( -800 ); } -void QuickFind::LastMatchPosition::set( LineNumber line, LineColumn column ) +void QuickFind::LastMatchPosition::set( LineNumber line, const LineColumn& column ) { if ( ( !line_.has_value() ) || ( ( line <= *line_ ) && ( column < column_ ) ) ) { line_ = line; @@ -84,7 +84,7 @@ void QuickFind::LastMatchPosition::set( const FilePosition& position ) set( position.line(), position.column() ); } -bool QuickFind::LastMatchPosition::isLater( OptionalLineNumber line, LineColumn column ) const +bool QuickFind::LastMatchPosition::isLater( OptionalLineNumber line, const LineColumn& column ) const { if ( !line_.has_value() || !line.has_value() ) return false; @@ -101,7 +101,7 @@ bool QuickFind::LastMatchPosition::isLater( const FilePosition& position ) const return isLater( position.line(), position.column() ); } -bool QuickFind::LastMatchPosition::isSooner( OptionalLineNumber line, LineColumn column ) const +bool QuickFind::LastMatchPosition::isSooner( OptionalLineNumber line, const LineColumn& column ) const { if ( !line_.has_value() || !line.has_value() ) return false; diff --git a/src/ui/src/quickfindpattern.cpp b/src/ui/src/quickfindpattern.cpp index ebf85e293..8e85484e7 100644 --- a/src/ui/src/quickfindpattern.cpp +++ b/src/ui/src/quickfindpattern.cpp @@ -52,7 +52,7 @@ constexpr Qt::GlobalColor QfForeColor = Qt::black; -bool QuickFindMatcher::isLineMatching( const QString& line, LineColumn column ) const +bool QuickFindMatcher::isLineMatching( const QString& line, const LineColumn& column ) const { if ( !isActive_ ) return false; @@ -68,7 +68,7 @@ bool QuickFindMatcher::isLineMatching( const QString& line, LineColumn column ) } } -bool QuickFindMatcher::isLineMatchingBackward( const QString& line, LineColumn column ) const +bool QuickFindMatcher::isLineMatchingBackward( const QString& line, const LineColumn& column ) const { if ( !isActive_ ) return false; diff --git a/src/ui/src/selection.cpp b/src/ui/src/selection.cpp index 348d997a6..39b49abc2 100644 --- a/src/ui/src/selection.cpp +++ b/src/ui/src/selection.cpp @@ -39,7 +39,7 @@ Selection::Selection() selectedRange_.endLine = 0_lnum; } -void Selection::selectPortion( LineNumber line, LineColumn startColumn, LineColumn endColumn ) +void Selection::selectPortion( LineNumber line, const LineColumn& startColumn, const LineColumn& endColumn ) { // First unselect any whole line or range selectedLine_ = {}; @@ -113,8 +113,8 @@ bool Selection::isLineSelected( LineNumber line ) const return false; } -bool Selection::isPortionSelected( LineNumber line, LineColumn startColumn, - LineColumn endColumn ) const +bool Selection::isPortionSelected( LineNumber line, const LineColumn& startColumn, + const LineColumn& endColumn ) const { if ( isLineSelected( line ) ) { return true; diff --git a/src/utils/include/crc32.h b/src/utils/include/crc32.h index 51f8646f1..c2de9fdef 100644 --- a/src/utils/include/crc32.h +++ b/src/utils/include/crc32.h @@ -24,7 +24,7 @@ class Crc32 { public: - static quint32 calculate( QByteArray text ) + static quint32 calculate( const QByteArray& text ) { quint32 crc32 = 0xffffffff; for ( auto i = 0; i < text.size(); ++i ) { @@ -76,4 +76,4 @@ class Crc32 { 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; }; -#endif \ No newline at end of file +#endif diff --git a/src/versioncheck/include/versionchecker.h b/src/versioncheck/include/versionchecker.h index 486e25eeb..8025f31e4 100644 --- a/src/versioncheck/include/versionchecker.h +++ b/src/versioncheck/include/versionchecker.h @@ -94,7 +94,7 @@ class VersionChecker : public QObject { void downloadFinished( QNetworkReply* ); private: - void checkVersionData( QByteArray versionData ); + void checkVersionData( const QByteArray& versionData ); private: QNetworkAccessManager* manager_ = nullptr; diff --git a/src/versioncheck/src/versionchecker.cpp b/src/versioncheck/src/versionchecker.cpp index 3e867f5c2..b146a78ff 100644 --- a/src/versioncheck/src/versionchecker.cpp +++ b/src/versioncheck/src/versionchecker.cpp @@ -150,7 +150,7 @@ void VersionChecker::downloadFinished( QNetworkReply* reply ) config.save(); } -void VersionChecker::checkVersionData( QByteArray versionData ) +void VersionChecker::checkVersionData( const QByteArray& versionData ) { LOG_DEBUG << "Version reply: " << QString::fromUtf8( versionData ); @@ -194,4 +194,4 @@ void VersionChecker::checkVersionData( QByteArray versionData ) Q_EMIT newVersionFound( latestVersion, url, changes ); } -} \ No newline at end of file +}