fix previous stage buffer performance opt
This commit is contained in:
parent
9efca3a7b4
commit
cbf7e661d2
@ -1291,6 +1291,7 @@ SC_FUNC void stgbuffer_cleanup(void)
|
|||||||
if (stgbuf!=NULL) {
|
if (stgbuf!=NULL) {
|
||||||
free(stgbuf);
|
free(stgbuf);
|
||||||
stgbuf=NULL;
|
stgbuf=NULL;
|
||||||
|
stglen=0;
|
||||||
stgmax=0;
|
stgmax=0;
|
||||||
} /* if */
|
} /* if */
|
||||||
if (stgpipe!=NULL) {
|
if (stgpipe!=NULL) {
|
||||||
@ -1324,6 +1325,7 @@ SC_FUNC void stgmark(char mark)
|
|||||||
if (staging) {
|
if (staging) {
|
||||||
CHECK_STGBUFFER(stgidx);
|
CHECK_STGBUFFER(stgidx);
|
||||||
stgbuf[stgidx++]=mark;
|
stgbuf[stgidx++]=mark;
|
||||||
|
stglen++;
|
||||||
} /* if */
|
} /* if */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1379,14 +1381,15 @@ SC_FUNC void stgwrite(const char *st)
|
|||||||
while (*st!='\0') { /* copy to staging buffer */
|
while (*st!='\0') { /* copy to staging buffer */
|
||||||
CHECK_STGBUFFER(stgidx);
|
CHECK_STGBUFFER(stgidx);
|
||||||
stgbuf[stgidx++]=*st++;
|
stgbuf[stgidx++]=*st++;
|
||||||
|
stglen++;
|
||||||
} /* while */
|
} /* while */
|
||||||
CHECK_STGBUFFER(stgidx);
|
CHECK_STGBUFFER(stgidx);
|
||||||
stgbuf[stgidx++]='\0';
|
stgbuf[stgidx++]='\0';
|
||||||
} else {
|
} else {
|
||||||
len=(stgbuf!=NULL) ? stglen : 0;
|
len=(stgbuf!=NULL) ? stglen : 0;
|
||||||
st_len=strlen(st);
|
st_len = strlen(st);
|
||||||
CHECK_STGBUFFER(len+st_len+1);
|
CHECK_STGBUFFER(len+st_len+1);
|
||||||
memcpy(stgbuf + len, st, st_len + 1); //strcat(stgbuf,st);
|
memcpy(stgbuf + len, st, st_len + 1); //strcat(stgbuf,st);
|
||||||
len=len+st_len;
|
len=len+st_len;
|
||||||
stglen=len;
|
stglen=len;
|
||||||
if (len>0 && stgbuf[len-1]=='\n') {
|
if (len>0 && stgbuf[len-1]=='\n') {
|
||||||
@ -1419,6 +1422,7 @@ SC_FUNC void stgout(int index)
|
|||||||
/* first pass: sub-expressions */
|
/* first pass: sub-expressions */
|
||||||
if (sc_status==statWRITE)
|
if (sc_status==statWRITE)
|
||||||
reordered=stgstring(&stgbuf[index],&stgbuf[stgidx]);
|
reordered=stgstring(&stgbuf[index],&stgbuf[stgidx]);
|
||||||
|
stglen=stgidx-index;
|
||||||
stgidx=index;
|
stgidx=index;
|
||||||
|
|
||||||
/* second pass: optimize the buffer created in the first pass */
|
/* second pass: optimize the buffer created in the first pass */
|
||||||
@ -1568,10 +1572,11 @@ SC_FUNC void stgset(int onoff)
|
|||||||
/* write any contents that may be put in the buffer by stgwrite()
|
/* write any contents that may be put in the buffer by stgwrite()
|
||||||
* when "staging" was 0
|
* when "staging" was 0
|
||||||
*/
|
*/
|
||||||
if (strlen(stgbuf)>0)
|
if (stglen>0)
|
||||||
filewrite(stgbuf);
|
filewrite(stgbuf);
|
||||||
} /* if */
|
} /* if */
|
||||||
stgbuf[0]='\0';
|
stgbuf[0]='\0';
|
||||||
|
stglen=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_OPT_VARS 5
|
#define MAX_OPT_VARS 5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user