textfile.cpp: small performance improvements
- Pass std::string by reference - Don't construct path using format()
This commit is contained in:
parent
4eacb00b43
commit
87e9892a88
@ -14,8 +14,8 @@ class TextFile
|
||||
{
|
||||
public:
|
||||
TextFile();
|
||||
void Load(std::string filename);
|
||||
bool TryLoad(std::string filename);
|
||||
void Load(const std::string &filename);
|
||||
bool TryLoad(const std::string &filename);
|
||||
size_t LineCount() const;
|
||||
const std::string &Line(size_t id) const;
|
||||
|
||||
|
@ -13,7 +13,7 @@ TextFile::TextFile() : lines{}
|
||||
{
|
||||
}
|
||||
|
||||
bool TextFile::TryLoad(std::string name)
|
||||
bool TextFile::TryLoad(const std::string &name)
|
||||
{
|
||||
if (name.length() == 0)
|
||||
return false;
|
||||
@ -33,9 +33,9 @@ bool TextFile::TryLoad(std::string name)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextFile::Load(std::string name)
|
||||
void TextFile::Load(const std::string &name)
|
||||
{
|
||||
std::string filename = format(DATA_PATH "/", name);
|
||||
std::string filename = DATA_PATH "/" + name;
|
||||
std::ifstream file(filename, std::ios::in);
|
||||
if (file.bad())
|
||||
{
|
||||
|
Reference in New Issue
Block a user