Skip to content

Commit f097f2c

Browse files
committed
refactor: reserve wrappedLinesNumbers and replace to emplace if possible
1 parent edc7582 commit f097f2c

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

src/ui/include/predefinedfilterscombobox.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PredefinedFiltersComboBox final : public QComboBox {
5858
PredefinedFiltersComboBox& operator=( PredefinedFiltersComboBox&& other ) = delete;
5959

6060
void populatePredefinedFilters();
61-
void updateSearchPattern( const QString newSearchPattern, bool useLogicalCombining );
61+
void updateSearchPattern( const QString& newSearchPattern, bool useLogicalCombining );
6262

6363
virtual void showPopup();
6464

src/ui/src/abstractlogview.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class WrappedLinesView {
231231
explicit WrappedLinesView( const QString& longLine, LineLength visibleColumns )
232232
{
233233
if ( longLine.isEmpty() ) {
234-
wrappedLines_.push_back( WrappedString{} );
234+
wrappedLines_.emplace_back( );
235235
}
236236
else {
237237
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
@@ -264,7 +264,7 @@ class WrappedLinesView {
264264
if ( wrappedLines_.size() == 1 ) {
265265
auto& wrappedLine = wrappedLines_.front();
266266
auto len = std::min( length.get(), getLength( wrappedLine ) - start.get() );
267-
resultChunks.push_back( wrappedLine.mid( start.get(), ( len > 0 ? len : 0 ) ) );
267+
resultChunks.emplace_back( wrappedLine.mid( start.get(), ( len > 0 ? len : 0 ) ) );
268268
return resultChunks;
269269
}
270270

@@ -281,7 +281,7 @@ class WrappedLinesView {
281281
auto chunkLength = length.get();
282282
while ( positionInWrappedLine + chunkLength
283283
> getLength( wrappedLines_[ wrappedLineIndex ] ) ) {
284-
resultChunks.push_back(
284+
resultChunks.emplace_back(
285285
wrappedLines_[ wrappedLineIndex ].mid( positionInWrappedLine ) );
286286
wrappedLineIndex++;
287287
positionInWrappedLine = 0;
@@ -294,7 +294,7 @@ class WrappedLinesView {
294294
if ( chunkLength > 0 ) {
295295
auto& wrappedLine = wrappedLines_[ wrappedLineIndex ];
296296
auto len = std::min( chunkLength, getLength( wrappedLine ) - positionInWrappedLine );
297-
resultChunks.push_back(
297+
resultChunks.emplace_back(
298298
wrappedLine.mid( positionInWrappedLine, ( len > 0 ? len : 0 ) ) );
299299
}
300300

@@ -2668,8 +2668,9 @@ void AbstractLogView::drawTextArea( QPaintDevice* paintDevice )
26682668
painter->drawText( lineNumberAreaStartX + LineNumberPadding, yPos + fontAscent,
26692669
lineNumberStr );
26702670
}
2671+
wrappedLinesNumbers_.reserve(wrappedLineView.wrappedLinesCount());
26712672
for ( auto i = 0u; i < wrappedLineView.wrappedLinesCount(); ++i ) {
2672-
wrappedLinesNumbers_.push_back( std::make_pair( lineNumber, i ) );
2673+
wrappedLinesNumbers_.emplace_back( lineNumber, i );
26732674
}
26742675

26752676
yPos += finalLineHeight;

src/ui/src/highlighterset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ HighlighterMatchType HighlighterSet::matchLine( const QString& line,
251251
matchType = HighlighterMatchType::WordMatch;
252252
}
253253

254-
matches.insert( matches.end(), std::make_move_iterator( thisMatches.begin() ),
254+
matches.emplace( matches.end(), std::make_move_iterator( thisMatches.begin() ),
255255
std::make_move_iterator( thisMatches.end() ) );
256256
}
257257
}

src/ui/src/predefinedfilterscombobox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void PredefinedFiltersComboBox::populatePredefinedFilters()
114114
this->setModel( model_ );
115115
}
116116

117-
void PredefinedFiltersComboBox::updateSearchPattern( const QString newSearchPattern, bool useLogicalCombining )
117+
void PredefinedFiltersComboBox::updateSearchPattern( const QString& newSearchPattern, bool useLogicalCombining )
118118
{
119119
searchPattern_.newOne_ = newSearchPattern;
120120
searchPattern_.useLogicalCombining_ = useLogicalCombining;

src/ui/src/selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Selection::getSelectionWithLineNumbers( const AbstractLogData* logData ) const
211211

212212
for ( const auto& line : list ) {
213213
selectionData.emplace( logData->getLineNumber( ln ), line );
214-
ln++;
214+
++ln;
215215
}
216216
}
217217

0 commit comments

Comments
 (0)