ruby-changes:53919
From: duerst <ko1@a...>
Date: Mon, 3 Dec 2018 08:28:48 +0900 (JST)
Subject: [ruby-changes:53919] duerst:r66139 (trunk): remove unnecessary settings with NULL_NODE in \X implementation
duerst 2018-12-03 08:28:42 +0900 (Mon, 03 Dec 2018) New Revision: 66139 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66139 Log: remove unnecessary settings with NULL_NODE in \X implementation Remove unnecessary settings of node_array elements to NULL_NODE. We can do this because we initialize the whole array to NULL_NODEs and set everything again to NULL_NODEs when creating a sequence or alternative node. Also, fix an index error in the initialization of node_array. (issue #15343) Modified files: trunk/regparse.c Index: regparse.c =================================================================== --- regparse.c (revision 66138) +++ regparse.c (revision 66139) @@ -5849,7 +5849,7 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L5849 Node **seq = node_array; /* seq[5] */ Node **alts = node_array+5; /* alts[4] */ - for (i=0; i<8; i++) + for (i=0; i<NODE_ARRAY_SIZE; i++) node_array[i] = NULL_NODE; if (propname2ctype(env, "Grapheme_Cluster_Break=Extend") < 0) goto err; @@ -5932,7 +5932,6 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L5932 R_ERR(create_property_node(seq+1, env, "Grapheme_Cluster_Break=LVT")); R_ERR(quantify_property_node(seq+2, env, "Grapheme_Cluster_Break=T", '*')); - seq[3] = NULL_NODE; R_ERR(create_sequence_node(&list2, seq)); } @@ -5948,7 +5947,6 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L5947 R_ERR(quantify_property_node(seq+2, env, "Grapheme_Cluster_Break=V", '*')); R_ERR(quantify_property_node(seq+3, env, "Grapheme_Cluster_Break=T", '*')); - seq[4] = NULL_NODE; R_ERR(create_sequence_node(&list2, seq)); } @@ -5963,7 +5961,6 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L5961 R_ERR(quantify_property_node(seq+1, env, "Grapheme_Cluster_Break=V", '+')); R_ERR(quantify_property_node(seq+2, env, "Grapheme_Cluster_Break=T", '*')); - seq[3] = NULL_NODE; R_ERR(create_sequence_node(&list2, seq)); } @@ -5996,7 +5993,6 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L5993 if (IS_NULL(seq[1])) goto err; R_ERR(quantify_node(seq+1, 0, 1)); - seq[2] = NULL_NODE; R_ERR(create_sequence_node(alts+0, seq)); } @@ -6011,7 +6007,6 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L6007 R_ERR(quantify_property_node(seq+1, env, "Grapheme_Cluster_Break=Extend", '*')); - seq[2] = NULL_NODE; R_ERR(create_sequence_node(alts+1, seq)); } @@ -6021,11 +6016,9 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L6016 R_ERR(quantify_property_node(seq+1, env, "Grapheme_Cluster_Break=Extend", '*')); R_ERR(quantify_property_node(seq+2, env, "Grapheme_Cluster_Break=E_Modifier", '?')); - seq[3] = NULL_NODE; R_ERR(create_sequence_node(alts+2, seq)); } - alts[3] = NULL_NODE; R_ERR(create_alternate_node(&alt2, alts)); } @@ -6108,7 +6101,6 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L6101 R_ERR(quantify_property_node(seq+2, env, "Grapheme_Cluster_Break=E_Modifier", '?')); - seq[3] = NULL_NODE; R_ERR(create_sequence_node(&list2, seq)); } /* End of ZWJ (E_Base_GAZ | Glue_After_Zwj) E_Modifier? */ @@ -6167,7 +6159,6 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L6159 if (IS_NULL(seq[1])) goto err; R_ERR(quantify_node(seq+1, 0, 1)); - seq[2] = NULL_NODE; R_ERR(create_sequence_node(&list2, seq)); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/