speed up PF_VarString a little

This commit is contained in:
Bill Currie 2007-06-09 09:43:21 +00:00 committed by Jeff Teunissen
parent d93670df3b
commit 4973a38cce
3 changed files with 13 additions and 6 deletions

View file

@ -64,15 +64,19 @@ VISIBLE const char *pr_gametype = "";
VISIBLE char *
PF_VarString (progs_t *pr, int first)
{
char *out;
char *out, *dst;
const char *src;
int len, i;
for (len = 0, i = first; i < pr->pr_argc; i++)
len += strlen (P_GSTRING (pr, i));
out = Hunk_TempAlloc (len + 1);
out[0] = 0;
for (i = first; i < pr->pr_argc; i++)
strcat (out, P_GSTRING (pr, i));
dst = out = Hunk_TempAlloc (len + 1);
for (i = first; i < pr->pr_argc; i++) {
src = P_GSTRING (pr, i);
while (*src)
*dst++ = *src++;
}
*dst = 0;
return out;
}

View file

@ -108,6 +108,8 @@ init_qf (void)
Sys_Init_Cvars ();
Cmd_Init ();
Memory_Init (malloc (1024 * 1024), 1024 * 1024);
Cvar_Get ("pr_debug", "1", 0, 0, 0);
Cvar_Get ("pr_boundscheck", "0", 0, 0, 0);

View file

@ -58,11 +58,12 @@ void () test_str =
print (a + b + c + d);
printf ("%i \"%.5s\" %3.4f %v\n", 14, "hi there", 3.1415926, '4 1 3');
};
void (...) dprint = #0;
integer (integer argc, string []argv) main =
{
local integer i;
local SEL sel;
dprint ("foo", "bar\n");
for (i = 0; i < argc; i++) {
print (argv[i]);
print ("\n");