diff --git a/src/ui/include/predefinedfilterscombobox.h b/src/ui/include/predefinedfilterscombobox.h index 1554cf195..59a536af7 100644 --- a/src/ui/include/predefinedfilterscombobox.h +++ b/src/ui/include/predefinedfilterscombobox.h @@ -58,7 +58,7 @@ class PredefinedFiltersComboBox final : public QComboBox { PredefinedFiltersComboBox& operator=( PredefinedFiltersComboBox&& other ) = delete; void populatePredefinedFilters(); - void updateSearchPattern( const QString newSearchPattern, bool useLogicalCombining ); + void updateSearchPattern( const QString& newSearchPattern, bool useLogicalCombining ); virtual void showPopup(); diff --git a/src/ui/include/selection.h b/src/ui/include/selection.h index fddd43e8f..1a788da07 100644 --- a/src/ui/include/selection.h +++ b/src/ui/include/selection.h @@ -162,7 +162,7 @@ class Selection { FilePosition getPreviousPosition() const; private: - std::map + std::vector> getSelectionWithLineNumbers( const AbstractLogData* logData ) const; private: diff --git a/src/ui/src/abstractlogview.cpp b/src/ui/src/abstractlogview.cpp index e4694a776..2625661c0 100644 --- a/src/ui/src/abstractlogview.cpp +++ b/src/ui/src/abstractlogview.cpp @@ -231,7 +231,7 @@ class WrappedLinesView { explicit WrappedLinesView( const QString& longLine, LineLength visibleColumns ) { if ( longLine.isEmpty() ) { - wrappedLines_.push_back( WrappedString{} ); + wrappedLines_.emplace_back( ); } else { #if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) @@ -264,7 +264,7 @@ class WrappedLinesView { if ( wrappedLines_.size() == 1 ) { auto& wrappedLine = wrappedLines_.front(); auto len = std::min( length.get(), getLength( wrappedLine ) - start.get() ); - resultChunks.push_back( wrappedLine.mid( start.get(), ( len > 0 ? len : 0 ) ) ); + resultChunks.emplace_back( wrappedLine.mid( start.get(), ( len > 0 ? len : 0 ) ) ); return resultChunks; } @@ -281,7 +281,7 @@ class WrappedLinesView { auto chunkLength = length.get(); while ( positionInWrappedLine + chunkLength > getLength( wrappedLines_[ wrappedLineIndex ] ) ) { - resultChunks.push_back( + resultChunks.emplace_back( wrappedLines_[ wrappedLineIndex ].mid( positionInWrappedLine ) ); wrappedLineIndex++; positionInWrappedLine = 0; @@ -294,7 +294,7 @@ class WrappedLinesView { if ( chunkLength > 0 ) { auto& wrappedLine = wrappedLines_[ wrappedLineIndex ]; auto len = std::min( chunkLength, getLength( wrappedLine ) - positionInWrappedLine ); - resultChunks.push_back( + resultChunks.emplace_back( wrappedLine.mid( positionInWrappedLine, ( len > 0 ? len : 0 ) ) ); } @@ -2668,8 +2668,9 @@ void AbstractLogView::drawTextArea( QPaintDevice* paintDevice ) painter->drawText( lineNumberAreaStartX + LineNumberPadding, yPos + fontAscent, lineNumberStr ); } + wrappedLinesNumbers_.reserve(wrappedLineView.wrappedLinesCount()); for ( auto i = 0u; i < wrappedLineView.wrappedLinesCount(); ++i ) { - wrappedLinesNumbers_.push_back( std::make_pair( lineNumber, i ) ); + wrappedLinesNumbers_.emplace_back( lineNumber, i ); } yPos += finalLineHeight; diff --git a/src/ui/src/predefinedfilterscombobox.cpp b/src/ui/src/predefinedfilterscombobox.cpp index 0f557938f..f49b33048 100644 --- a/src/ui/src/predefinedfilterscombobox.cpp +++ b/src/ui/src/predefinedfilterscombobox.cpp @@ -114,7 +114,7 @@ void PredefinedFiltersComboBox::populatePredefinedFilters() this->setModel( model_ ); } -void PredefinedFiltersComboBox::updateSearchPattern( const QString newSearchPattern, bool useLogicalCombining ) +void PredefinedFiltersComboBox::updateSearchPattern( const QString& newSearchPattern, bool useLogicalCombining ) { searchPattern_.newOne_ = newSearchPattern; searchPattern_.useLogicalCombining_ = useLogicalCombining; diff --git a/src/ui/src/selection.cpp b/src/ui/src/selection.cpp index 348d997a6..03843aca4 100644 --- a/src/ui/src/selection.cpp +++ b/src/ui/src/selection.cpp @@ -189,29 +189,30 @@ QString Selection::getSelectedText( const AbstractLogData* logData, bool lineNum return text; } -std::map +std::vector> Selection::getSelectionWithLineNumbers( const AbstractLogData* logData ) const { - std::map selectionData; + std::vector> selectionData; if ( selectedLine_.has_value() ) { - selectionData.emplace( logData->getLineNumber( selectedLine_.value() ), + selectionData.emplace_back( logData->getLineNumber( selectedLine_.value() ), logData->getLineString( *selectedLine_ ) ); } else if ( selectedPartial_.line.has_value() ) { - selectionData.emplace( + selectionData.emplace_back( logData->getLineNumber( selectedPartial_.line.value() ), logData->getExpandedLineString( *selectedPartial_.line ) .mid( selectedPartial_.startColumn.get(), selectedPartial_.size().get() ) ); } else if ( selectedRange_.startLine.has_value() ) { - const auto list = logData->getLines( *selectedRange_.startLine, selectedRange_.size() ); - LineNumber ln = *selectedRange_.startLine; + const auto list = logData->getLines( selectedRange_.startLine.value(), selectedRange_.size() ); + LineNumber ln = selectedRange_.startLine.value(); + selectionData.reserve(list.size()); for ( const auto& line : list ) { - selectionData.emplace( logData->getLineNumber( ln ), line ); - ln++; + selectionData.emplace_back( logData->getLineNumber( ln ), line ); + ++ln; } }