Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
  • Loading branch information
YoannQDQ and nyalldawson committed Mar 30, 2023
1 parent a083874 commit f7410c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/analysis/processing/qgsalgorithmrandomextract.cpp
Expand Up @@ -124,12 +124,13 @@ QVariantMap QgsRandomExtractAlgorithm::processAlgorithm( const QVariantMap &para

// If the number of features to select is greater than half the total number of features
// we will instead randomly select features to *exclude* from the output layer
size_t actualFeatureCount = allFeats.size();
size_t shuffledFeatureCount = number;
bool invertSelection = number > count / 2;
bool invertSelection = static_cast< size_t>( number ) > actualFeatureCount / 2;
if ( invertSelection )
shuffledFeatureCount = count - number;
shuffledFeatureCount = actualFeatureCount - number;

size_t nb = count;
size_t nb = actualFeatureCount;

// Shuffle <number> features at the start of the iterator
feedback->pushInfo( QObject::tr( "Randomly select %1 features" ).arg( number ) );
Expand Down

0 comments on commit f7410c6

Please sign in to comment.