From 2a5c6ba1193331fb7481b8ac023f8ff7d919eef3 Mon Sep 17 00:00:00 2001 From: Andrea Cedraro Date: Sun, 2 Nov 2014 23:20:18 +0100 Subject: [PATCH] Swap the order of parameters in ResultAnd --- cpp/ycm/PythonSupport.cpp | 14 +++++++------- cpp/ycm/Result.h | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cpp/ycm/PythonSupport.cpp b/cpp/ycm/PythonSupport.cpp index ce2ef96768..8aa682905b 100644 --- a/cpp/ycm/PythonSupport.cpp +++ b/cpp/ycm/PythonSupport.cpp @@ -84,7 +84,7 @@ boost::python::list FilterAndSortCandidates( std::vector< const Candidate * > repository_candidates = CandidatesFromObjectList( candidates, candidate_property ); - std::vector< ResultAnd< int > > object_and_results; + std::vector< ResultAnd< int > > result_and_objects; { ReleaseGil unlock; Bitset query_bitset = LetterBitsetFromString( query ); @@ -100,17 +100,17 @@ boost::python::list FilterAndSortCandidates( query_has_uppercase_letters ); if ( result.IsSubsequence() ) { - ResultAnd< int > object_and_result( i, result ); - object_and_results.push_back( boost::move( object_and_result ) ); + ResultAnd< int > result_and_object( result, i ); + result_and_objects.push_back( boost::move( result_and_object ) ); } } - std::sort( object_and_results.begin(), object_and_results.end() ); + std::sort( result_and_objects.begin(), result_and_objects.end() ); } - foreach ( const ResultAnd< int > &object_and_result, - object_and_results ) { - filtered_candidates.append( candidates[ object_and_result.extra_object_ ] ); + foreach ( const ResultAnd< int > &result_and_object, + result_and_objects ) { + filtered_candidates.append( candidates[ result_and_object.extra_object_ ] ); } return filtered_candidates; diff --git a/cpp/ycm/Result.h b/cpp/ycm/Result.h index 20475dc5c1..b2f4188744 100644 --- a/cpp/ycm/Result.h +++ b/cpp/ycm/Result.h @@ -88,8 +88,7 @@ class Result { template< class T > struct ResultAnd { - // TODO: Swap the order of these parameters - ResultAnd( T extra_object, const Result &result ) + ResultAnd( const Result &result, T extra_object ) : extra_object_( extra_object ), result_( result ) {} bool operator< ( const ResultAnd &other ) const { @@ -102,7 +101,7 @@ struct ResultAnd { template< class T > struct ResultAnd { - ResultAnd( const T *extra_object, const Result &result ) + ResultAnd( const Result &result, const T *extra_object ) : extra_object_( extra_object ), result_( result ) {} bool operator< ( const ResultAnd &other ) const {