ruby-changes:45500
From: nobu <ko1@a...>
Date: Wed, 8 Feb 2017 10:19:01 +0900 (JST)
Subject: [ruby-changes:45500] nobu:r57573 (trunk): node.c: compress logop sequence
nobu 2017-02-08 10:18:56 +0900 (Wed, 08 Feb 2017) New Revision: 57573 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57573 Log: node.c: compress logop sequence * node.c (dump_node): compress sequence of same logical binary operators, NODE_AND/NODE_OR. Modified files: trunk/node.c Index: node.c =================================================================== --- node.c (revision 57572) +++ node.c (revision 57573) @@ -158,6 +158,7 @@ dump_node(VALUE buf, VALUE indent, int c https://github.com/ruby/ruby/blob/trunk/node.c#L158 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 c https://github.com/ruby/ruby/blob/trunk/node.c#L167 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 c https://github.com/ruby/ruby/blob/trunk/node.c#L336 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/