Get rid of the temporary buffer in IniFile's Load function.
std::getline is the string-based equivalent.
This commit is contained in:
parent
e0edf31608
commit
eca70d1562
|
@ -328,9 +328,6 @@ void IniFile::SortSections()
|
||||||
|
|
||||||
bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||||
{
|
{
|
||||||
// Maximum number of letters in a line
|
|
||||||
static const int MAX_BYTES = 1024*32;
|
|
||||||
|
|
||||||
if (!keep_current_data)
|
if (!keep_current_data)
|
||||||
sections.clear();
|
sections.clear();
|
||||||
// first section consists of the comments before the first real section
|
// first section consists of the comments before the first real section
|
||||||
|
@ -339,18 +336,15 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||||
std::ifstream in;
|
std::ifstream in;
|
||||||
OpenFStream(in, filename, std::ios::in);
|
OpenFStream(in, filename, std::ios::in);
|
||||||
|
|
||||||
if (in.fail()) return false;
|
if (in.fail())
|
||||||
|
return false;
|
||||||
|
|
||||||
Section* current_section = nullptr;
|
Section* current_section = nullptr;
|
||||||
while (!in.eof())
|
while (!in.eof())
|
||||||
{
|
{
|
||||||
char templine[MAX_BYTES];
|
|
||||||
std::string line;
|
std::string line;
|
||||||
if (in.getline(templine, MAX_BYTES))
|
|
||||||
{
|
if (!std::getline(in, line))
|
||||||
line = templine;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (in.eof())
|
if (in.eof())
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue