source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Increase performance by stashing the list type in struct
@ 2010-05-17 23:57 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-05-17 23:57 UTC (permalink / raw)
  To: source

Log Message:
-----------
Increase performance by stashing the list type in struct mdoc_node.
This will eventually be used so that mdoc_macro can known whether to
dump list line arguments into the body (`Bl -column' overflowing).

Remove a2list() and arg_listtype() because of this.

Modified Files:
--------------
    mdocml:
        libmdoc.h
        mdoc.h
        mdoc_action.c
        mdoc_html.c
        mdoc_term.c
        mdoc_validate.c

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.79 -r1.80
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -568,27 +568,19 @@ pre_bl(PRE_ARGS)
 		case (MDOC_Inset):
 			/* FALLTHROUGH */
 		case (MDOC_Column):
-			/*
-			 * Note that if a duplicate is detected, we
-			 * remove the duplicate instead of passing it
-			 * over.  If we don't do this, mdoc_action will
-			 * become confused when it scans over multiple
-			 * types whilst setting its bitmasks.
-			 *
-			 * FIXME: this should occur in mdoc_action.c.
-			 */
-			if (type >= 0) {
-				if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP))
-					return(0);
-				mdoc_argn_free(n->args, pos);
+			if (type < 0) {
+				type = n->args->argv[pos].arg;
 				break;
 			}
-			type = n->args->argv[pos].arg;
-			break;
+			if (mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP))
+				break;
+			return(0);
 		case (MDOC_Compact):
-			if (type < 0 && ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
-				return(0);
-			break;
+			if (type >= 0)
+				break;
+			if (mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
+				break;
+			return(0);
 		case (MDOC_Width):
 			if (width >= 0)
 				if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP))
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.65 -r1.66
--- mdoc_html.c
+++ mdoc_html.c
@@ -57,8 +57,6 @@ static	void		  print_mdoc_nodelist(MDOC_
 static	void		  a2width(const char *, struct roffsu *);
 static	void		  a2offs(const char *, struct roffsu *);
 
-static	int		  a2list(const struct mdoc_node *);
-
 static	void		  mdoc_root_post(MDOC_ARGS);
 static	int		  mdoc_root_pre(MDOC_ARGS);
 
@@ -98,11 +96,11 @@ static	void		  mdoc_fo_post(MDOC_ARGS);
 static	int		  mdoc_fo_pre(MDOC_ARGS);
 static	int		  mdoc_ic_pre(MDOC_ARGS);
 static	int		  mdoc_in_pre(MDOC_ARGS);
-static	int		  mdoc_it_block_pre(MDOC_ARGS, int, int,
-				struct roffsu *, struct roffsu *);
-static	int		  mdoc_it_head_pre(MDOC_ARGS, int, 
+static	int		  mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list,
+				int, struct roffsu *, struct roffsu *);
+static	int		  mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list, 
 				struct roffsu *);
-static	int		  mdoc_it_body_pre(MDOC_ARGS, int);
+static	int		  mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list);
 static	int		  mdoc_it_pre(MDOC_ARGS);
 static	int		  mdoc_lb_pre(MDOC_ARGS);
 static	int		  mdoc_li_pre(MDOC_ARGS);
@@ -277,50 +275,6 @@ html_mdoc(void *arg, const struct mdoc *
 
 
 /*
- * Return the list type for `Bl', e.g., `Bl -column' returns 
- * MDOC_Column.  This can ONLY be run for lists; it will abort() if no
- * list type is found. 
- */
-static int
-a2list(const struct mdoc_node *n)
-{
-	int		 i;
-
-	assert(n->args);
-	for (i = 0; i < (int)n->args->argc; i++) 
-		switch (n->args->argv[i].arg) {
-		case (MDOC_Enum):
-			/* FALLTHROUGH */
-		case (MDOC_Dash):
-			/* FALLTHROUGH */
-		case (MDOC_Hyphen):
-			/* FALLTHROUGH */
-		case (MDOC_Bullet):
-			/* FALLTHROUGH */
-		case (MDOC_Tag):
-			/* FALLTHROUGH */
-		case (MDOC_Hang):
-			/* FALLTHROUGH */
-		case (MDOC_Inset):
-			/* FALLTHROUGH */
-		case (MDOC_Diag):
-			/* FALLTHROUGH */
-		case (MDOC_Item):
-			/* FALLTHROUGH */
-		case (MDOC_Column):
-			/* FALLTHROUGH */
-		case (MDOC_Ohang):
-			return(n->args->argv[i].arg);
-		default:
-			break;
-		}
-
-	abort();
-	/* NOTREACHED */
-}
-
-
-/*
  * Calculate the scaling unit passed in a `-width' argument.  This uses
  * either a native scaling unit (e.g., 1i, 2m) or the string length of
  * the value.
@@ -868,7 +822,7 @@ mdoc_bx_pre(MDOC_ARGS)
 
 /* ARGSUSED */
 static int
-mdoc_it_block_pre(MDOC_ARGS, int type, int comp,
+mdoc_it_block_pre(MDOC_ARGS, enum mdoc_list type, int comp,
 		struct roffsu *offs, struct roffsu *width)
 {
 	struct htmlpair	 	 tag;
@@ -880,13 +834,13 @@ mdoc_it_block_pre(MDOC_ARGS, int type, i
 
 	/* XXX: see notes in mdoc_it_pre(). */
 
-	if (MDOC_Column == type) {
+	if (LIST_column == type) {
 		/* Don't width-pad on the left. */
 		SCALE_HS_INIT(width, 0);
 		/* Also disallow non-compact. */
 		comp = 1;
 	}
-	if (MDOC_Diag == type)
+	if (LIST_diag == type)
 		/* Mandate non-compact with empty prior. */
 		if (n->prev && NULL == n->prev->body->child)
 			comp = 1;
@@ -923,17 +877,17 @@ mdoc_it_block_pre(MDOC_ARGS, int type, i
 
 /* ARGSUSED */
 static int
-mdoc_it_body_pre(MDOC_ARGS, int type)
+mdoc_it_body_pre(MDOC_ARGS, enum mdoc_list type)
 {
 	struct htmlpair	 tag;
 	struct roffsu	 su;
 
 	switch (type) {
-	case (MDOC_Item):
+	case (LIST_item):
 		/* FALLTHROUGH */
-	case (MDOC_Ohang):
+	case (LIST_ohang):
 		/* FALLTHROUGH */
-	case (MDOC_Column):
+	case (LIST_column):
 		break;
 	default:
 		/* 
@@ -953,19 +907,19 @@ mdoc_it_body_pre(MDOC_ARGS, int type)
 
 /* ARGSUSED */
 static int
-mdoc_it_head_pre(MDOC_ARGS, int type, struct roffsu *width)
+mdoc_it_head_pre(MDOC_ARGS, enum mdoc_list type, struct roffsu *width)
 {
 	struct htmlpair	 tag;
 	struct ord	*ord;
 	char		 nbuf[BUFSIZ];
 
 	switch (type) {
-	case (MDOC_Item):
+	case (LIST_item):
 		return(0);
-	case (MDOC_Ohang):
+	case (LIST_ohang):
 		print_otag(h, TAG_DIV, 0, &tag);
 		return(1);
-	case (MDOC_Column):
+	case (LIST_column):
 		bufcat_su(h, "min-width", width);
 		bufcat_style(h, "clear", "none");
 		if (n->next && MDOC_HEAD == n->next->type)
@@ -989,24 +943,24 @@ mdoc_it_head_pre(MDOC_ARGS, int type, st
 	}
 
 	switch (type) {
-	case (MDOC_Diag):
+	case (LIST_diag):
 		PAIR_CLASS_INIT(&tag, "diag");
 		print_otag(h, TAG_SPAN, 1, &tag);
 		break;
-	case (MDOC_Enum):
+	case (LIST_enum):
 		ord = h->ords.head;
 		assert(ord);
 		nbuf[BUFSIZ - 1] = 0;
 		(void)snprintf(nbuf, BUFSIZ - 1, "%d.", ord->pos++);
 		print_text(h, nbuf);
 		return(0);
-	case (MDOC_Dash):
+	case (LIST_dash):
 		print_text(h, "\\(en");
 		return(0);
-	case (MDOC_Hyphen):
+	case (LIST_hyphen):
 		print_text(h, "\\(hy");
 		return(0);
-	case (MDOC_Bullet):
+	case (LIST_bullet):
 		print_text(h, "\\(bu");
 		return(0);
 	default:
@@ -1020,9 +974,10 @@ mdoc_it_head_pre(MDOC_ARGS, int type, st
 static int
 mdoc_it_pre(MDOC_ARGS)
 {
-	int			 i, type, wp, comp;
+	int			 i, wp, comp;
 	const struct mdoc_node	*bl, *nn;
 	struct roffsu		 width, offs;
+	enum mdoc_list		 type;
 
 	/* 
 	 * XXX: be very careful in changing anything, here.  Lists in
@@ -1034,20 +989,20 @@ mdoc_it_pre(MDOC_ARGS)
 	if (MDOC_BLOCK != n->type)
 		bl = bl->parent;
 
-	type = a2list(bl);
+	type = bl->data.list;
 
 	/* Set default width and offset. */
 
 	SCALE_HS_INIT(&offs, 0);
 
 	switch (type) {
-	case (MDOC_Enum):
+	case (LIST_enum):
 		/* FALLTHROUGH */
-	case (MDOC_Dash):
+	case (LIST_dash):
 		/* FALLTHROUGH */
-	case (MDOC_Hyphen):
+	case (LIST_hyphen):
 		/* FALLTHROUGH */
-	case (MDOC_Bullet):
+	case (LIST_bullet):
 		SCALE_HS_INIT(&width, 2);
 		break;
 	default:
@@ -1078,13 +1033,13 @@ mdoc_it_pre(MDOC_ARGS)
 	/* Override width in some cases. */
 
 	switch (type) {
-	case (MDOC_Ohang):
+	case (LIST_ohang):
 		/* FALLTHROUGH */
-	case (MDOC_Item):
+	case (LIST_item):
 		/* FALLTHROUGH */
-	case (MDOC_Inset):
+	case (LIST_inset):
 		/* FALLTHROUGH */
-	case (MDOC_Diag):
+	case (LIST_diag):
 		SCALE_HS_INIT(&width, 0);
 		break;
 	default:
@@ -1103,7 +1058,7 @@ mdoc_it_pre(MDOC_ARGS)
 
 	/* Override column widths. */
 
-	if (MDOC_Column == type) {
+	if (LIST_column == type) {
 		nn = n->parent->child;
 		for (i = 0; nn && nn != n; nn = nn->next, i++)
 			/* Counter... */ ;
@@ -1125,7 +1080,7 @@ mdoc_bl_pre(MDOC_ARGS)
 		return(0);
 	if (MDOC_BLOCK != n->type)
 		return(1);
-	if (MDOC_Enum != a2list(n))
+	if (MDOC_Enum != n->data.list)
 		return(1);
 
 	ord = malloc(sizeof(struct ord));
@@ -1149,7 +1104,7 @@ mdoc_bl_post(MDOC_ARGS)
 
 	if (MDOC_BLOCK != n->type)
 		return;
-	if (MDOC_Enum != a2list(n))
+	if (MDOC_Enum != n->data.list)
 		return;
 
 	ord = h->ords.head;
Index: mdoc_action.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_action.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -Lmdoc_action.c -Lmdoc_action.c -u -p -r1.59 -r1.60
--- mdoc_action.c
+++ mdoc_action.c
@@ -33,7 +33,7 @@
 #include "libmandoc.h"
 
 #define	POST_ARGS struct mdoc *m, struct mdoc_node *n
-#define	PRE_ARGS  struct mdoc *m, const struct mdoc_node *n
+#define	PRE_ARGS  struct mdoc *m, struct mdoc_node *n
 
 #define	NUMSIZ	  32
 #define	DATESIZ	  32
@@ -216,7 +216,7 @@ static	const enum mdoct rsord[RSORD_MAX]
 
 
 int
-mdoc_action_pre(struct mdoc *m, const struct mdoc_node *n)
+mdoc_action_pre(struct mdoc *m, struct mdoc_node *n)
 {
 
 	switch (n->type) {
@@ -942,8 +942,63 @@ pre_offset(PRE_ARGS)
 static int
 pre_bl(PRE_ARGS)
 {
+	int		 pos;
 
-	return(MDOC_BLOCK == n->type ? pre_offset(m, n) : 1);
+	if (MDOC_BLOCK != n->type) {
+		assert(n->parent);
+		assert(MDOC_BLOCK == n->parent->type);
+		assert(MDOC_Bl == n->parent->tok);
+		assert(LIST__NONE != n->parent->data.list);
+		n->data.list = n->parent->data.list;
+		return(1);
+	}
+
+	assert(LIST__NONE == n->data.list);
+
+	for (pos = 0; pos < (int)n->args->argc; pos++) {
+		switch (n->args->argv[pos].arg) {
+		case (MDOC_Bullet):
+			n->data.list = LIST_bullet;
+			break;
+		case (MDOC_Dash):
+			n->data.list = LIST_dash;
+			break;
+		case (MDOC_Enum):
+			n->data.list = LIST_enum;
+			break;
+		case (MDOC_Hyphen):
+			n->data.list = LIST_hyphen;
+			break;
+		case (MDOC_Item):
+			n->data.list = LIST_item;
+			break;
+		case (MDOC_Tag):
+			n->data.list = LIST_tag;
+			break;
+		case (MDOC_Diag):
+			n->data.list = LIST_diag;
+			break;
+		case (MDOC_Hang):
+			n->data.list = LIST_hang;
+			break;
+		case (MDOC_Ohang):
+			n->data.list = LIST_ohang;
+			break;
+		case (MDOC_Inset):
+			n->data.list = LIST_inset;
+			break;
+		case (MDOC_Column):
+			n->data.list = LIST_column;
+			break;
+		default:
+			break;
+		}
+		if (LIST__NONE != n->data.list)
+			break;
+	}
+
+	assert(LIST__NONE != n->data.list);
+	return(pre_offset(m, n));
 }
 
 
Index: libmdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.48 -r1.49
--- libmdoc.h
+++ libmdoc.h
@@ -177,7 +177,7 @@ int		  mdoc_valid_pre(struct mdoc *, 
 			const struct mdoc_node *);
 int		  mdoc_valid_post(struct mdoc *);
 int		  mdoc_action_pre(struct mdoc *, 
-			const struct mdoc_node *);
+			struct mdoc_node *);
 int		  mdoc_action_post(struct mdoc *);
 enum margverr	  mdoc_argv(struct mdoc *, int, enum mdoct,
 			struct mdoc_arg **, int *, char *);
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.125 -r1.126
--- mdoc_term.c
+++ mdoc_term.c
@@ -61,7 +61,6 @@ static	int	  arg_getattrs(const int *, i
 			const struct mdoc_node *);
 static	int	  arg_getattr(int, const struct mdoc_node *);
 static	int	  arg_disptype(const struct mdoc_node *);
-static	int	  arg_listtype(const struct mdoc_node *);
 static	void	  print_bvspace(struct termp *,
 			const struct mdoc_node *,
 			const struct mdoc_node *);
@@ -512,47 +511,6 @@ arg_disptype(const struct mdoc_node *n)
 }
 
 
-static int
-arg_listtype(const struct mdoc_node *n)
-{
-	int		 i, len;
-
-	assert(MDOC_BLOCK == n->type);
-
-	len = (int)(n->args ? n->args->argc : 0);
-
-	for (i = 0; i < len; i++) 
-		switch (n->args->argv[i].arg) {
-		case (MDOC_Bullet):
-			/* FALLTHROUGH */
-		case (MDOC_Dash):
-			/* FALLTHROUGH */
-		case (MDOC_Enum):
-			/* FALLTHROUGH */
-		case (MDOC_Hyphen):
-			/* FALLTHROUGH */
-		case (MDOC_Tag):
-			/* FALLTHROUGH */
-		case (MDOC_Inset):
-			/* FALLTHROUGH */
-		case (MDOC_Diag):
-			/* FALLTHROUGH */
-		case (MDOC_Item):
-			/* FALLTHROUGH */
-		case (MDOC_Column):
-			/* FALLTHROUGH */
-		case (MDOC_Hang):
-			/* FALLTHROUGH */
-		case (MDOC_Ohang):
-			return(n->args->argv[i].arg);
-		default:
-			break;
-		}
-
-	return(-1);
-}
-
-
 static size_t
 a2offs(const struct mdoc_argv *arg)
 {
@@ -655,13 +613,13 @@ print_bvspace(struct termp *p, 
 
 	/* A `-column' does not assert vspace within the list. */
 
-	if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Column, bl))
+	if (MDOC_Bl == bl->tok && LIST_diag == bl->data.list)
 		if (n->prev && MDOC_It == n->prev->tok)
 			return;
 
 	/* A `-diag' without body does not vspace. */
 
-	if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Diag, bl)) 
+	if (MDOC_Bl == bl->tok && LIST_diag == bl->data.list)
 		if (n->prev && MDOC_It == n->prev->tok) {
 			assert(n->prev->body);
 			if (NULL == n->prev->body->child)
@@ -705,8 +663,9 @@ termp_it_pre(DECL_ARGS)
 {
 	const struct mdoc_node *bl, *nn;
 	char		        buf[7];
-	int		        i, type, keys[3], vals[3];
+	int		        i, keys[3], vals[3];
 	size_t		        width, offset, ncols, dcol;
+	enum mdoc_list		type;
 
 	if (MDOC_BLOCK == n->type) {
 		print_bvspace(p, n->parent->parent, n);
@@ -725,8 +684,7 @@ termp_it_pre(DECL_ARGS)
 
 	arg_getattrs(keys, vals, 3, bl);
 
-	type = arg_listtype(bl);
-	assert(-1 != type);
+	type = bl->data.list;
 
 	/* 
 	 * First calculate width and offset.  This is pretty easy unless
@@ -740,7 +698,7 @@ termp_it_pre(DECL_ARGS)
 		offset = a2offs(&bl->args->argv[vals[1]]);
 
 	switch (type) {
-	case (MDOC_Column):
+	case (LIST_column):
 		if (MDOC_BODY == n->type)
 			break;
 		/*
@@ -798,25 +756,25 @@ termp_it_pre(DECL_ARGS)
 	 */
 
 	switch (type) {
-	case (MDOC_Bullet):
+	case (LIST_bullet):
 		/* FALLTHROUGH */
-	case (MDOC_Dash):
+	case (LIST_dash):
 		/* FALLTHROUGH */
-	case (MDOC_Hyphen):
+	case (LIST_hyphen):
 		if (width < 4)
 			width = 4;
 		break;
-	case (MDOC_Enum):
+	case (LIST_enum):
 		if (width < 5)
 			width = 5;
 		break;
-	case (MDOC_Hang):
+	case (LIST_hang):
 		if (0 == width)
 			width = 8;
 		break;
-	case (MDOC_Column):
+	case (LIST_column):
 		/* FALLTHROUGH */
-	case (MDOC_Tag):
+	case (LIST_tag):
 		if (0 == width)
 			width = 10;
 		break;
@@ -832,11 +790,11 @@ termp_it_pre(DECL_ARGS)
 	p->flags |= TERMP_NOSPACE;
 
 	switch (type) {
-	case (MDOC_Diag):
+	case (LIST_diag):
 		if (MDOC_BODY == n->type)
 			term_word(p, "\\ \\ ");
 		break;
-	case (MDOC_Inset):
+	case (LIST_inset):
 		if (MDOC_BODY == n->type) 
 			term_word(p, "\\ ");
 		break;
@@ -847,7 +805,7 @@ termp_it_pre(DECL_ARGS)
 	p->flags |= TERMP_NOSPACE;
 
 	switch (type) {
-	case (MDOC_Diag):
+	case (LIST_diag):
 		if (MDOC_HEAD == n->type)
 			term_fontpush(p, TERMFONT_BOLD);
 		break;
@@ -863,19 +821,19 @@ termp_it_pre(DECL_ARGS)
 	 */
 
 	switch (type) {
-	case (MDOC_Bullet):
+	case (LIST_bullet):
 		/* FALLTHROUGH */
-	case (MDOC_Dash):
+	case (LIST_dash):
 		/* FALLTHROUGH */
-	case (MDOC_Enum):
+	case (LIST_enum):
 		/* FALLTHROUGH */
-	case (MDOC_Hyphen):
+	case (LIST_hyphen):
 		if (MDOC_HEAD == n->type)
 			p->flags |= TERMP_NOBREAK;
 		else
 			p->flags |= TERMP_NOLPAD;
 		break;
-	case (MDOC_Hang):
+	case (LIST_hang):
 		if (MDOC_HEAD == n->type)
 			p->flags |= TERMP_NOBREAK;
 		else
@@ -898,7 +856,7 @@ termp_it_pre(DECL_ARGS)
 		} else
 			p->flags |= TERMP_HANG;
 		break;
-	case (MDOC_Tag):
+	case (LIST_tag):
 		if (MDOC_HEAD == n->type)
 			p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE;
 		else
@@ -909,7 +867,7 @@ termp_it_pre(DECL_ARGS)
 		if (NULL == n->next || NULL == n->next->child)
 			p->flags |= TERMP_DANGLE;
 		break;
-	case (MDOC_Column):
+	case (LIST_column):
 		if (MDOC_HEAD == n->type) {
 			assert(n->next);
 			if (MDOC_BODY == n->next->type)
@@ -920,7 +878,7 @@ termp_it_pre(DECL_ARGS)
 				p->flags |= TERMP_NOLPAD;
 		}
 		break;
-	case (MDOC_Diag):
+	case (LIST_diag):
 		if (MDOC_HEAD == n->type)
 			p->flags |= TERMP_NOBREAK;
 		break;
@@ -937,7 +895,7 @@ termp_it_pre(DECL_ARGS)
 	p->offset += offset;
 
 	switch (type) {
-	case (MDOC_Hang):
+	case (LIST_hang):
 		/*
 		 * Same stipulation as above, regarding `-hang'.  We
 		 * don't want to recalculate rmargin and offsets when
@@ -948,22 +906,22 @@ termp_it_pre(DECL_ARGS)
 				 MDOC_Bd == n->next->child->tok))
 			break;
 		/* FALLTHROUGH */
-	case (MDOC_Bullet):
+	case (LIST_bullet):
 		/* FALLTHROUGH */
-	case (MDOC_Dash):
+	case (LIST_dash):
 		/* FALLTHROUGH */
-	case (MDOC_Enum):
+	case (LIST_enum):
 		/* FALLTHROUGH */
-	case (MDOC_Hyphen):
+	case (LIST_hyphen):
 		/* FALLTHROUGH */
-	case (MDOC_Tag):
+	case (LIST_tag):
 		assert(width);
 		if (MDOC_HEAD == n->type)
 			p->rmargin = p->offset + width;
 		else 
 			p->offset += width;
 		break;
-	case (MDOC_Column):
+	case (LIST_column):
 		assert(width);
 		p->rmargin = p->offset + width;
 		/* 
@@ -986,19 +944,19 @@ termp_it_pre(DECL_ARGS)
 
 	if (MDOC_HEAD == n->type)
 		switch (type) {
-		case (MDOC_Bullet):
+		case (LIST_bullet):
 			term_fontpush(p, TERMFONT_BOLD);
 			term_word(p, "\\[bu]");
 			term_fontpop(p);
 			break;
-		case (MDOC_Dash):
+		case (LIST_dash):
 			/* FALLTHROUGH */
-		case (MDOC_Hyphen):
+		case (LIST_hyphen):
 			term_fontpush(p, TERMFONT_BOLD);
 			term_word(p, "\\(hy");
 			term_fontpop(p);
 			break;
-		case (MDOC_Enum):
+		case (LIST_enum):
 			(pair->ppair->ppair->count)++;
 			snprintf(buf, sizeof(buf), "%d.", 
 					pair->ppair->ppair->count);
@@ -1013,19 +971,19 @@ termp_it_pre(DECL_ARGS)
 	 */
 
 	switch (type) {
-	case (MDOC_Bullet):
+	case (LIST_bullet):
 		/* FALLTHROUGH */
-	case (MDOC_Item):
+	case (LIST_item):
 		/* FALLTHROUGH */
-	case (MDOC_Dash):
+	case (LIST_dash):
 		/* FALLTHROUGH */
-	case (MDOC_Hyphen):
+	case (LIST_hyphen):
 		/* FALLTHROUGH */
-	case (MDOC_Enum):
+	case (LIST_enum):
 		if (MDOC_HEAD == n->type)
 			return(0);
 		break;
-	case (MDOC_Column):
+	case (LIST_column):
 		if (MDOC_BODY == n->type)
 			return(0);
 		break;
@@ -1041,24 +999,23 @@ termp_it_pre(DECL_ARGS)
 static void
 termp_it_post(DECL_ARGS)
 {
-	int		   type;
+	enum mdoc_list	   type;
 
 	if (MDOC_BLOCK == n->type)
 		return;
 
-	type = arg_listtype(n->parent->parent->parent);
-	assert(-1 != type);
+	type = n->parent->parent->parent->data.list;
 
 	switch (type) {
-	case (MDOC_Item):
+	case (LIST_item):
 		/* FALLTHROUGH */
-	case (MDOC_Diag):
+	case (LIST_diag):
 		/* FALLTHROUGH */
-	case (MDOC_Inset):
+	case (LIST_inset):
 		if (MDOC_BODY == n->type)
 			term_flushln(p);
 		break;
-	case (MDOC_Column):
+	case (LIST_column):
 		if (MDOC_HEAD == n->type)
 			term_flushln(p);
 		break;
Index: mdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -Lmdoc.h -Lmdoc.h -u -p -r1.81 -r1.82
--- mdoc.h
+++ mdoc.h
@@ -247,6 +247,21 @@ struct 	mdoc_arg {
 	unsigned int	  refcnt;
 };
 
+enum	mdoc_list {
+	LIST__NONE = 0,
+	LIST_bullet,
+	LIST_column,
+	LIST_dash,
+	LIST_diag,
+	LIST_enum,
+	LIST_hang,
+	LIST_hyphen,
+	LIST_inset,
+	LIST_item,
+	LIST_ohang,
+	LIST_tag
+};
+
 /* Node in AST. */
 struct	mdoc_node {
 	struct mdoc_node *parent; /* parent AST node */
@@ -272,6 +287,10 @@ struct	mdoc_node {
 	struct mdoc_node *body;		/* BLOCK */
 	struct mdoc_node *tail;		/* BLOCK */
 	char		 *string;	/* TEXT */
+
+	union {
+		enum mdoc_list list; /* for `Bl' nodes */
+	} data;
 };
 
 #define	MDOC_IGN_SCOPE	 (1 << 0) /* Ignore scope violations. */
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-17 23:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-17 23:57 mdocml: Increase performance by stashing the list type in struct kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).