Adding const in a few more places

This commit is contained in:
Strahinja Val Markovic 2012-05-07 22:27:08 -07:00
parent 0110611996
commit d421c43f65
2 changed files with 12 additions and 10 deletions

View File

@ -110,7 +110,7 @@ void Completer::AddCandidatesToDatabase(
const std::string &filetype,
const std::string &filepath )
{
std::vector< Candidate *> &candidates =
std::vector< const Candidate *> &candidates =
GetCandidateVector( filetype, filepath );
int num_candidates = new_candidates.size();
@ -120,8 +120,8 @@ void Completer::AddCandidatesToDatabase(
for (int i = 0; i < num_candidates; ++i)
{
const std::string &candidate_text = new_candidates[ i ];
Candidate *&candidate = GetValueElseInsert( candidate_repository_,
candidate_text, NULL );
const Candidate *&candidate = GetValueElseInsert( candidate_repository_,
candidate_text, NULL );
if ( !candidate )
candidate = new Candidate( candidate_text );
@ -199,7 +199,7 @@ void Completer::ResultsForQueryAndType( const std::string &query,
foreach ( const FilepathToCandidates::value_type &path_and_candidates,
*it->second )
{
foreach ( Candidate* candidate, *path_and_candidates.second )
foreach ( const Candidate* candidate, *path_and_candidates.second )
{
if ( !candidate->MatchesQueryBitset( query_bitset ) )
continue;
@ -214,7 +214,7 @@ void Completer::ResultsForQueryAndType( const std::string &query,
}
std::vector< Candidate* >& Completer::GetCandidateVector(
std::vector< const Candidate* >& Completer::GetCandidateVector(
const std::string &filetype,
const std::string &filepath )
{
@ -224,11 +224,11 @@ std::vector< Candidate* >& Completer::GetCandidateVector(
if ( !path_to_candidates )
path_to_candidates.reset( new FilepathToCandidates() );
boost::shared_ptr< std::vector< Candidate* > > &candidates =
boost::shared_ptr< std::vector< const Candidate* > > &candidates =
(*path_to_candidates)[ filepath ];
if ( !candidates )
candidates.reset( new std::vector< Candidate* >() );
candidates.reset( new std::vector< const Candidate* >() );
return *candidates;
}

View File

@ -37,11 +37,13 @@ namespace YouCompleteMe
typedef boost::python::list Pylist;
// candidate text string -> candidate objects
typedef boost::unordered_map< std::string, Candidate* > CandidateRepository;
typedef boost::unordered_map< std::string, const Candidate* >
CandidateRepository;
// filepath -> *( *candidate )
typedef boost::unordered_map< std::string,
boost::shared_ptr< std::vector< Candidate* > > > FilepathToCandidates;
boost::shared_ptr< std::vector< const Candidate* > > >
FilepathToCandidates;
// filetype -> *( filepath -> *( *candidate ) )
typedef boost::unordered_map< std::string,
@ -93,7 +95,7 @@ private:
const std::string &filetype,
std::vector< Result > &results ) const;
std::vector< Candidate* >& GetCandidateVector(
std::vector< const Candidate* >& GetCandidateVector(
const std::string &filetype,
const std::string &filepath );