diff --git a/cpp/ycm/ClangCompleter/ClangCompleter.cpp b/cpp/ycm/ClangCompleter/ClangCompleter.cpp index d03684a7..c7239c44 100644 --- a/cpp/ycm/ClangCompleter/ClangCompleter.cpp +++ b/cpp/ycm/ClangCompleter/ClangCompleter.cpp @@ -59,7 +59,7 @@ ClangCompleter::~ClangCompleter() { std::vector< Diagnostic > ClangCompleter::DiagnosticsForFile( - std::string filename ) { + const std::string &filename ) { shared_ptr< TranslationUnit > unit = translation_unit_store_.Get( filename ); if ( !unit ) @@ -83,9 +83,9 @@ bool ClangCompleter::UpdatingTranslationUnit( const std::string &filename ) { void ClangCompleter::UpdateTranslationUnit( - std::string filename, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ) { + const std::string &filename, + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ) { bool translation_unit_created; shared_ptr< TranslationUnit > unit = translation_unit_store_.GetOrCreate( filename, @@ -114,11 +114,11 @@ void ClangCompleter::UpdateTranslationUnit( std::vector< CompletionData > ClangCompleter::CandidatesForLocationInFile( - std::string filename, + const std::string &filename, int line, int column, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ) { + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ) { shared_ptr< TranslationUnit > unit = translation_unit_store_.GetOrCreate( filename, unsaved_files, flags ); @@ -132,11 +132,11 @@ ClangCompleter::CandidatesForLocationInFile( Location ClangCompleter::GetDeclarationLocation( - std::string filename, + const std::string &filename, int line, int column, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ) { + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ) { shared_ptr< TranslationUnit > unit = translation_unit_store_.GetOrCreate( filename, unsaved_files, flags ); @@ -149,11 +149,11 @@ Location ClangCompleter::GetDeclarationLocation( Location ClangCompleter::GetDefinitionLocation( - std::string filename, + const std::string &filename, int line, int column, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ) { + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ) { shared_ptr< TranslationUnit > unit = translation_unit_store_.GetOrCreate( filename, unsaved_files, flags ); @@ -165,7 +165,7 @@ Location ClangCompleter::GetDefinitionLocation( } -void ClangCompleter::DeleteCachesForFile( std::string filename ) { +void ClangCompleter::DeleteCachesForFile( const std::string &filename ) { translation_unit_store_.Remove( filename ); } diff --git a/cpp/ycm/ClangCompleter/ClangCompleter.h b/cpp/ycm/ClangCompleter/ClangCompleter.h index 5218f4e5..70fb3252 100644 --- a/cpp/ycm/ClangCompleter/ClangCompleter.h +++ b/cpp/ycm/ClangCompleter/ClangCompleter.h @@ -37,48 +37,43 @@ struct Location; typedef std::vector< CompletionData > CompletionDatas; -// TODO: document that all filename parameters must be absolute paths +// All filename parameters must be absolute paths. class ClangCompleter : boost::noncopyable { public: ClangCompleter(); ~ClangCompleter(); - std::vector< Diagnostic > DiagnosticsForFile( std::string filename ); + std::vector< Diagnostic > DiagnosticsForFile( const std::string &filename ); bool UpdatingTranslationUnit( const std::string &filename ); - // NOTE: params are taken by value on purpose! With a C++11 compiler we can - // avoid internal copies if params are taken by value (move ctors FTW), and we - // need to ensure we own the memory. - // TODO: Change some of these params back to const ref where possible after we - // get the server up. void UpdateTranslationUnit( - std::string filename, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ); + const std::string &filename, + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ); std::vector< CompletionData > CandidatesForLocationInFile( - std::string filename, + const std::string &filename, int line, int column, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ); + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ); Location GetDeclarationLocation( - std::string filename, + const std::string &filename, int line, int column, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ); + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ); Location GetDefinitionLocation( - std::string filename, + const std::string &filename, int line, int column, - std::vector< UnsavedFile > unsaved_files, - std::vector< std::string > flags ); + const std::vector< UnsavedFile > &unsaved_files, + const std::vector< std::string > &flags ); - void DeleteCachesForFile( std::string filename ); + void DeleteCachesForFile( const std::string &filename ); private: