From a2f7d03d4ef7f606680894693f52150a8eb1ac28 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 23 Jul 2014 15:28:37 +0200 Subject: rc: fix slow Xqdol(), avoid recursion in conclist(), estrdup(), avoid copying Xqdol() used to take quadratic time because of strcat(), the code isnt really needed as list2str() aready does the same thing in linear time without the strcat(). add estrdup() which uses emalloc() so allocation error are catched. move strdups() of name from callers into newvar(). avoid recursion of conclist(), and avoid copying of word strings by providing Newword() function which doesnt copy the word string. --- sys/src/cmd/rc/code.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/src/cmd/rc/code.c') diff --git a/sys/src/cmd/rc/code.c b/sys/src/cmd/rc/code.c index 3618838e3..7d1abbb3a 100644 --- a/sys/src/cmd/rc/code.c +++ b/sys/src/cmd/rc/code.c @@ -56,7 +56,7 @@ void cleanhere(char *f) { emitf(Xdelhere); - emits(strdup(f)); + emits(estrdup(f)); } char* @@ -258,7 +258,7 @@ outcode(tree *t, int eflag) else{ emitf(Xmark); emitf(Xword); - emits(strdup("*")); + emits(estrdup("*")); emitf(Xdol); } emitf(Xmark); /* dummy value for Xlocal */ @@ -275,7 +275,7 @@ outcode(tree *t, int eflag) break; case WORD: emitf(Xword); - emits(strdup(t->str)); + emits(estrdup(t->str)); break; case DUP: if(t->rtype==DUPFD){ -- cgit v1.2.3