Skip to content

Commit

Permalink
Merge pull request ycm-core#50 from vheon/master
Browse files Browse the repository at this point in the history
Swap the order of parameters in ResultAnd
  • Loading branch information
Valloric committed Nov 3, 2014
2 parents 97c19ff + 2a5c6ba commit d0c0258
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions cpp/ycm/PythonSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions cpp/ycm/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -102,7 +101,7 @@ struct ResultAnd {

template< class T >
struct ResultAnd<T * > {
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 {
Expand Down

0 comments on commit d0c0258

Please sign in to comment.