Commit 3c7b7a77 authored by rdubner's avatar rdubner

Get rid of N*N/2 loop when building VARIABLE_STRING_xxx

parent c183e944
......@@ -105,7 +105,6 @@ CreateSymc(PARAMETERS &params,
*/
string fname = params.cbl_filename.GetFandExt();
stringstream ss_tab;
stringstream ss;
// Start off the output with the program section information:
......@@ -133,12 +132,15 @@ CreateSymc(PARAMETERS &params,
ss << "char VARIABLE_STRING_" << Upper(fname) << "[]=" << endl;
const int SEGMENT_LENGTH = 78;
while(s.length() > SEGMENT_LENGTH) {
ss << "\"" << s.substr(0,SEGMENT_LENGTH) << "\"" << endl;
s = s.substr(SEGMENT_LENGTH);
int walker = 0;
int remaining = (int)s.length();
while( remaining > SEGMENT_LENGTH ) {
ss << "\"" << s.substr(walker,SEGMENT_LENGTH) << "\"" << endl;
walker += SEGMENT_LENGTH;
remaining -= SEGMENT_LENGTH;
}
if( s.length() ) {
ss << "\"" << s << "\"" << endl;
if( remaining ) {
ss << "\"" << s.substr(walker) << "\"" << endl;
}
ss << ";" << endl << endl;
params.symc << ss.str();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment