Closed dzzie closed 3 years ago
That's a neat optimisation that doesn't appear to have any negative impacts. Can you please generate a pull request so that I can merge the changes?
sure, I will do a few more tests on it too then
one other addition I made that you might be interested in was to include the error messages directly into the class. sucks up a bit more memory with the strings but puts it all in one place. maybe wrap it in a #ifdef withErrorMsgs
char* s_errorNoError="no error";
char* s_errorFileNotFound="file not found";
char* s_errorFileNotOpen="file not open";
char* s_errorBufferTooSmall="buffer too small";
char* s_errorSeekError="seek error";
char* s_errorSectionNotFound="section not found";
char* s_errorKeyNotFound="key not found";
char* s_errorEndOfFile="end of file";
char* s_errorUnknownError="unknown error";
char* s_errorUnknownValue="unknown err value";
char* IniFile::getErrorText()
{
switch (_error) {
case IniFile::errorNoError: return IniFile::s_errorNoError;
case IniFile::errorFileNotFound: return IniFile::s_errorFileNotFound;
case IniFile::errorFileNotOpen: return IniFile::s_errorFileNotOpen;
case IniFile::errorBufferTooSmall: return IniFile::s_errorBufferTooSmall;
case IniFile::errorSeekError: return IniFile::s_errorSeekError;
case IniFile::errorSectionNotFound: return IniFile::s_errorSectionNotFound;
case IniFile::errorKeyNotFound: return IniFile::s_errorKeyNotFound;
case IniFile::errorEndOfFile: return IniFile::s_errorEndOfFile;
case IniFile::errorUnknownError: return IniFile::s_errorUnknownError;
default: return IniFile::s_errorUnknownValue;
}
}
Hi, just a thought in regards to:
This can be optimized a bit in the readLine scanner. If it detects that a line is a comment, it can scan ahead until the next new line, incrementing pos, but not being bound by the current buffer length limitation. By ignoring comment line length, you can trim allot off of your buffer sizes to only the longest variable line now.
I just did a quick hack to make it so, but it saves allot of memory and allows you to include verbose comments without having to be careful.