Don't realloc console lines quite so much. Should let spammy stuff like timedemos run a tiny smidge faster.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4479 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
571e6fe748
commit
18ac985526
|
@ -656,6 +656,7 @@ void Con_PrintCon (console_t *con, char *txt)
|
||||||
conchar_t expanded[4096];
|
conchar_t expanded[4096];
|
||||||
conchar_t *c;
|
conchar_t *c;
|
||||||
conline_t *oc;
|
conline_t *oc;
|
||||||
|
conline_t *reuse;
|
||||||
|
|
||||||
COM_ParseFunString(CON_WHITEMASK, txt, expanded, sizeof(expanded), false);
|
COM_ParseFunString(CON_WHITEMASK, txt, expanded, sizeof(expanded), false);
|
||||||
|
|
||||||
|
@ -673,6 +674,7 @@ void Con_PrintCon (console_t *con, char *txt)
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
con->cr = false;
|
con->cr = false;
|
||||||
|
reuse = NULL;
|
||||||
while (con->linecount >= con_maxlines.ival)
|
while (con->linecount >= con_maxlines.ival)
|
||||||
{
|
{
|
||||||
if (con->oldest == con->current)
|
if (con->oldest == con->current)
|
||||||
|
@ -686,7 +688,10 @@ void Con_PrintCon (console_t *con, char *txt)
|
||||||
if (con->display == con->oldest)
|
if (con->display == con->oldest)
|
||||||
con->display = con->oldest->newer;
|
con->display = con->oldest->newer;
|
||||||
con->oldest = con->oldest->newer;
|
con->oldest = con->oldest->newer;
|
||||||
Z_Free(con->oldest->older);
|
if (reuse)
|
||||||
|
Z_Free(con->oldest->older);
|
||||||
|
else
|
||||||
|
reuse = con->oldest->older;
|
||||||
con->oldest->older = NULL;
|
con->oldest->older = NULL;
|
||||||
con->linecount--;
|
con->linecount--;
|
||||||
}
|
}
|
||||||
|
@ -701,9 +706,20 @@ void Con_PrintCon (console_t *con, char *txt)
|
||||||
TTS_SayConString((conchar_t*)(con->current+1));
|
TTS_SayConString((conchar_t*)(con->current+1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
con->current->newer = Z_Malloc(sizeof(conline_t) + sizeof(conchar_t));
|
if (!reuse)
|
||||||
con->current->newer->older = con->current;
|
{
|
||||||
con->current = con->current->newer;
|
reuse = Z_Malloc(sizeof(conline_t) + sizeof(conchar_t));
|
||||||
|
reuse->maxlength = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reuse->newer = NULL;
|
||||||
|
reuse->older = NULL;
|
||||||
|
}
|
||||||
|
reuse->id = ++con->nextlineid;
|
||||||
|
reuse->older = con->current;
|
||||||
|
con->current->newer = reuse;
|
||||||
|
con->current = reuse;
|
||||||
con->current->length = 0;
|
con->current->length = 0;
|
||||||
o = (conchar_t *)(con->current+1)+con->current->length;
|
o = (conchar_t *)(con->current+1)+con->current->length;
|
||||||
*o = 0;
|
*o = 0;
|
||||||
|
@ -723,7 +739,13 @@ void Con_PrintCon (console_t *con, char *txt)
|
||||||
con->selendline = NULL;
|
con->selendline = NULL;
|
||||||
|
|
||||||
oc = con->current;
|
oc = con->current;
|
||||||
con->current = BZ_Realloc(con->current, sizeof(*con->current)+(con->current->length+2)*sizeof(conchar_t));
|
if (oc->length+2 > oc->maxlength)
|
||||||
|
{
|
||||||
|
oc->maxlength = (oc->length+2)+8;
|
||||||
|
if (oc->maxlength < oc->length)
|
||||||
|
oc->length = 0; //don't crash from console line overflows.
|
||||||
|
con->current = BZ_Realloc(con->current, sizeof(*con->current)+(oc->maxlength)*sizeof(conchar_t));
|
||||||
|
}
|
||||||
if (con->display == oc)
|
if (con->display == oc)
|
||||||
con->display = con->current;
|
con->display = con->current;
|
||||||
if (con->oldest == oc)
|
if (con->oldest == oc)
|
||||||
|
|
|
@ -102,7 +102,9 @@ typedef struct conline_s {
|
||||||
struct conline_s *older;
|
struct conline_s *older;
|
||||||
struct conline_s *newer;
|
struct conline_s *newer;
|
||||||
unsigned short length;
|
unsigned short length;
|
||||||
|
unsigned short maxlength;
|
||||||
unsigned short lines;
|
unsigned short lines;
|
||||||
|
unsigned short id;
|
||||||
float time;
|
float time;
|
||||||
} conline_t;
|
} conline_t;
|
||||||
|
|
||||||
|
@ -114,6 +116,7 @@ typedef struct conline_s {
|
||||||
typedef struct console_s
|
typedef struct console_s
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
|
int nextlineid; //the current line being written to. so we can rewrite links etc.
|
||||||
char name[64];
|
char name[64];
|
||||||
char title[64];
|
char title[64];
|
||||||
int linecount;
|
int linecount;
|
||||||
|
|
Loading…
Reference in New Issue