From d1b386a22423a646f1fd091d2cf724c6e3891793 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 8 Feb 2017 01:18:56 +0000 Subject: [PATCH] node.c: compress logop sequence * node.c (dump_node): compress sequence of same logical binary operators, NODE_AND/NODE_OR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- node.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/node.c b/node.c index 83b51e6a60..c5bdc39f68 100644 --- a/node.c +++ b/node.c @@ -158,6 +158,7 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node) int field_flag; int i; const char *next_indent = default_indent; + enum node_type type; if (!node) { D_NULL_NODE; @@ -166,7 +167,8 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node) D_NODE_HEADER(node); - switch (nd_type(node)) { + type = nd_type(node); + switch (type) { case NODE_BLOCK: ANN("statement sequence"); ANN("format: [nd_head]; ...; [nd_next]"); @@ -334,7 +336,12 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node) ANN("format: [nd_1st] || [nd_2nd]"); ANN("example: foo || bar"); andor: - F_NODE(nd_1st, "left expr"); + while (1) { + F_NODE(nd_1st, "left expr"); + if (!node->nd_2nd || nd_type(node->nd_2nd) != type) + break; + node = node->nd_2nd; + } LAST_NODE; F_NODE(nd_2nd, "right expr"); break;