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:
malte_langkabel
2017-05-04 10:55:16 +02:00
parent 55d3f9c189
commit 054b8fab17
156 changed files with 656 additions and 444 deletions
+6 -4
View File
@@ -5,17 +5,19 @@
#include <string>
#include <vector>
#include "utility/file/FilePath.h"
class TextAccess
{
public:
static std::shared_ptr<TextAccess> createFromFile(const std::string& filePath);
static std::shared_ptr<TextAccess> createFromFile(const FilePath& filePath);
static std::shared_ptr<TextAccess> createFromString(const std::string& text);
virtual ~TextAccess();
unsigned int getLineCount() const;
std::string getFilePath() const;
FilePath getFilePath() const;
/**
* @param lineNumber: starts with 1
@@ -30,7 +32,7 @@ public:
std::string getText() const;
private:
static std::vector<std::string> readFile(const std::string& filePath);
static std::vector<std::string> readFile(const FilePath& filePath);
static std::vector<std::string> splitStringByLines(const std::string& text);
TextAccess();
@@ -40,7 +42,7 @@ private:
bool checkIndexInRange(const unsigned int index) const;
bool checkIndexIntervalInRange(const unsigned int firstIndex, const unsigned int lastIndex) const;
std::string m_filePath;
FilePath m_filePath;
std::vector<std::string> m_lines;
};