summaryrefslogtreecommitdiffstats
path: root/bin/sh/expand.h
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-10-11 21:33:00 +0000
committerjilles <jilles@FreeBSD.org>2015-10-11 21:33:00 +0000
commit5edc3be36a94a4e6d00b23f4a78f7a34f298354a (patch)
treede27811dc69dd87b6197cb836792e2f49ede3869 /bin/sh/expand.h
parent4b946e6d78df59fc08a27d0a0830f287a59ff27f (diff)
downloadFreeBSD-src-5edc3be36a94a4e6d00b23f4a78f7a34f298354a.zip
FreeBSD-src-5edc3be36a94a4e6d00b23f4a78f7a34f298354a.tar.gz
sh: Make struct arglist an array instead of a linked list.
This simplifies the code (e.g. allowing use of qsort(3) instead of a hand-rolled mergesort) and should have better cache properties. The waste of unused args arrays after resizes is approximately the same as the savings from getting rid of the next pointers. At the same time, remove a piece of global state and move some duplicated code into a function.
Diffstat (limited to 'bin/sh/expand.h')
-rw-r--r--bin/sh/expand.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/bin/sh/expand.h b/bin/sh/expand.h
index 93c80f3..c377156 100644
--- a/bin/sh/expand.h
+++ b/bin/sh/expand.h
@@ -33,15 +33,11 @@
* $FreeBSD$
*/
-struct strlist {
- struct strlist *next;
- char *text;
-};
-
-
struct arglist {
- struct strlist *list;
- struct strlist **lastp;
+ char **args;
+ int count;
+ int capacity;
+ char *smallarg[1];
};
/*
@@ -55,6 +51,7 @@ struct arglist {
#define EXP_LIT_QUOTED 0x40 /* for EXP_SPLIT_LIT, start off quoted */
+void emptyarglist(struct arglist *);
union node;
void expandarg(union node *, struct arglist *, int);
void rmescapes(char *);
OpenPOWER on IntegriCloud