Clang completer method params are const ref again

They were temporarily all passed by-value until server-side threading issues
were resolved.
This commit is contained in:
Strahinja Val Markovic 2013-10-01 10:12:50 -07:00
parent 531e564a88
commit d63843ea4c
2 changed files with 29 additions and 34 deletions

View File

@ -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 );
}

View File

@ -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: