Commit f2ef8367

f2ef83671e50Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified

Description

refactor: remove dead per-type count-with-block branches

The generic count { ... } dispatch in compile_array_method_expr (added in the previous commit) short-circuits before the per-type branches, making the inline int_array and str_array count-with-block handlers unreachable. Remove them; the no-block count → length fallbacks stay.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
f2ef83671e50
Parent
70bd3a1d6e9d

spinel_codegen.rbmodifiedView file

@@ -13786,27 +13786,6 @@
1378613786 return "sp_IntArray_dup(" + rc + ")"
1378713787 end
1378813788 if mname == "count"
13789- if @nd_block[nid] >= 0
13790- # count with block
13791- blk = @nd_block[nid]
13792- bp = get_block_param(nid, 0)
13793- tmp = new_temp
13794- itmp = new_temp
13795- emit(" mrb_int " + tmp + " = 0;")
13796- emit(" for (mrb_int " + itmp + " = 0; " + itmp + " < sp_IntArray_length(" + rc + "); " + itmp + "++) {")
13797- emit(" mrb_int lv_" + bp + " = sp_IntArray_get(" + rc + ", " + itmp + ");")
13798- bbody = @nd_body[blk]
13799- bexpr = "0"
13800- if bbody >= 0
13801- bs = get_stmts(bbody)
13802- if bs.length > 0
13803- bexpr = compile_expr(bs.last)
13804- end
13805- end
13806- emit(" if (" + bexpr + ") " + tmp + "++;")
13807- emit(" }")
13808- return tmp
13809- end
1381013789 return "sp_IntArray_length(" + rc + ")"
1381113790 end
1381213791 if mname == "min_by"
@@ -13995,27 +13974,6 @@
1399513974 end
1399613975 end
1399713976 if mname == "count"
13998- if @nd_block[nid] >= 0
13999- blk = @nd_block[nid]
14000- bp = get_block_param(nid, 0)
14001- declare_var(bp, "string")
14002- tmp = new_temp
14003- itmp = new_temp
14004- emit(" mrb_int " + tmp + " = 0;")
14005- emit(" for (mrb_int " + itmp + " = 0; " + itmp + " < sp_StrArray_length(" + rc + "); " + itmp + "++) {")
14006- emit(" const char *lv_" + bp + " = sp_StrArray_get(" + rc + ", " + itmp + ");")
14007- bbody = @nd_body[blk]
14008- bexpr = "0"
14009- if bbody >= 0
14010- bs = get_stmts(bbody)
14011- if bs.length > 0
14012- bexpr = compile_expr(bs.last)
14013- end
14014- end
14015- emit(" if (" + bexpr + ") " + tmp + "++;")
14016- emit(" }")
14017- return tmp
14018- end
1401913977 return "sp_StrArray_length(" + rc + ")"
1402013978 end
1402113979 end