logic: reduce access to filesystem while indexing
* use canonical filepath cache in cxx indexer * made constructors of FilePath explicit * use FilePath at more places instead of string * forward declares FilePath wherever possible
This commit is contained in:
@@ -4,9 +4,14 @@
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
|
||||
CommentHandler::CommentHandler(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
|
||||
CommentHandler::CommentHandler(
|
||||
std::shared_ptr<ParserClient> client,
|
||||
std::shared_ptr<FileRegister> fileRegister,
|
||||
std::shared_ptr<FilePathCache> canonicalFilePathCache
|
||||
)
|
||||
: m_client(client)
|
||||
, m_fileRegister(fileRegister)
|
||||
, m_canonicalFilePathCache(canonicalFilePathCache)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -20,11 +25,11 @@ bool CommentHandler::HandleComment(clang::Preprocessor& preprocessor, clang::Sou
|
||||
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(sourceRange.getBegin(), false);
|
||||
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(sourceRange.getEnd(), false);
|
||||
|
||||
FilePath filePath = FilePath(presumedBegin.getFilename());
|
||||
FilePath filePath = m_canonicalFilePathCache->getValue(presumedBegin.getFilename());
|
||||
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsIndexed(filePath))
|
||||
{
|
||||
m_client->onCommentParsed(ParseLocation(
|
||||
presumedBegin.getFilename(),
|
||||
filePath,
|
||||
presumedBegin.getLine(),
|
||||
presumedBegin.getColumn(),
|
||||
presumedEnd.getLine(),
|
||||
|
||||
Reference in New Issue
Block a user