Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: added const reference function params if size > 16 #727

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/logdata/include/linetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/logdata/include/logdataworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class IndexingData {

// Atomically add to all the existing
// indexing data.
void addAll( const klogg::vector<char>& block, LineLength length,
void addAll( const klogg::vector<char>& block, const LineLength& length,
const FastLinePositionArray& linePosition, QTextCodec* encoding );

// Completely clear the indexing data.
Expand Down
1 change: 1 addition & 0 deletions src/logdata/include/logfiltereddataworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class SearchData {
// Atomically add to all the existing search data.
void addAll( LineLength length, const SearchResultArray& matches, LinesCount nbMatches,
LinesCount nbLinesProcessed );

// Get the number of matches
LinesCount getNbMatches() const;
// Get the last matched line number
Expand Down
1 change: 0 additions & 1 deletion src/logdata/src/logdataworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ QTextCodec* IndexingData::getForcedEncoding() const

void IndexingData::addAll( const klogg::vector<char>& block, LineLength length,
const FastLinePositionArray& newLinePosition, QTextCodec* encoding )

{
maxLength_ = std::max( maxLength_, length );
std::visit(
Expand Down
6 changes: 3 additions & 3 deletions src/ui/include/abstractlogview.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,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;
Expand Down Expand Up @@ -487,7 +487,7 @@ class AbstractLogView : public QAbstractScrollArea, public SearchableWidgetInter
// Utils functions
void updateGlobalSelection();

void selectAndDisplayRange( FilePosition pos );
void selectAndDisplayRange( const FilePosition& pos );
};

#endif
8 changes: 4 additions & 4 deletions src/ui/include/crawlerwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<LineNumber>& lines );
// Mark a line that has been clicked on the filtered (bottom) view.
Expand Down
4 changes: 2 additions & 2 deletions src/ui/include/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/ui/include/quickfind.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ 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()
{
line_ = {};
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:
Expand Down
4 changes: 2 additions & 2 deletions src/ui/include/quickfindpattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/ui/include/selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/src/abstractlogview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* (at your option) any later version.
*
* glogg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty o
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
Expand Down Expand Up @@ -1686,7 +1686,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 );
Expand Down Expand Up @@ -1981,7 +1981,7 @@ void AbstractLogView::updateGlobalSelection()
}
}

void AbstractLogView::selectAndDisplayRange( FilePosition pos )
void AbstractLogView::selectAndDisplayRange( const FilePosition& pos )
{
disableFollow();
selection_.selectRange( selectionStartPos_.line(), pos.line() );
Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/crawlerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,15 @@ 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,
nSymbols ); // FIXME: should be done with a signal.
}

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 );
Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
6 changes: 3 additions & 3 deletions src/ui/src/quickfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/quickfindpattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/src/selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_ = {};
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/include/crc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -76,4 +76,4 @@ class Crc32 {
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
};

#endif
#endif
2 changes: 1 addition & 1 deletion src/versioncheck/include/versionchecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/versioncheck/src/versionchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -194,4 +194,4 @@ void VersionChecker::checkVersionData( QByteArray versionData )

Q_EMIT newVersionFound( latestVersion, url, changes );
}
}
}
Loading