@@ -73,16 +73,17 @@ std::streampos sectionReader::findNormalString( const std::string& str, bool sem
7373}
7474
7575// NOTE different behavior than const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ) in read_func.cc
76- std::string * sectionReader::getDelimitedKeyword ( const char * delimiters ) {
77- std::string * str = new std::string ;
76+ const std::string * sectionReader::getDelimitedKeyword ( const char * delimiters ) {
77+ static std::string str;
7878 char c;
79- str->reserve (10 ); // seems to be faster and require less memory than no reserve or 20.
79+ // str->reserve(10); //seems to be faster and require less memory than no reserve or 20.
80+ str.clear ();
8081 skipWS ();
8182 while ( c = _file.get (), _file.good () ) {
8283 if ( c == ' -' || c == ' _' || isupper ( c ) || isdigit ( c ) ||
83- ( c == ' !' && str-> length () == 0 ) ) {
84- str-> append ( 1 , c );
85- } else if ( ( c == ' /' ) && ( _file.peek () == ' *' ) && ( str-> length () == 0 ) ) {
84+ ( c == ' !' && str. length () == 0 ) ) {
85+ str. append ( 1 , c );
86+ } else if ( ( c == ' /' ) && ( _file.peek () == ' *' ) && ( str. length () == 0 ) ) {
8687 // push past comment
8788 findNormalString ( " */" );
8889 skipWS ();
@@ -94,10 +95,10 @@ std::string * sectionReader::getDelimitedKeyword( const char * delimiters ) {
9495 }
9596 c = _file.peek ();
9697 if ( !strchr ( delimiters, c ) ) {
97- std::cerr << __PRETTY_FUNCTION__ << " : missing delimiter. Found " << c << " , expected one of " << delimiters << " at end of keyword " << * str << " . File offset: " << _file.tellg () << std::endl;
98+ std::cerr << __PRETTY_FUNCTION__ << " : missing delimiter. Found " << c << " , expected one of " << delimiters << " at end of keyword " << str << " . File offset: " << _file.tellg () << std::endl;
9899 abort ();
99100 }
100- return str;
101+ return & str;
101102}
102103
103104std::streampos sectionReader::seekInstanceEnd () {
0 commit comments