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
end1378813788
if mname == "count"13789-
if @nd_block[nid] >= 013790-
# count with block13791-
blk = @nd_block[nid]13792-
bp = get_block_param(nid, 0)13793-
tmp = new_temp13794-
itmp = new_temp13795-
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 >= 013801-
bs = get_stmts(bbody)13802-
if bs.length > 013803-
bexpr = compile_expr(bs.last)13804-
end13805-
end13806-
emit(" if (" + bexpr + ") " + tmp + "++;")13807-
emit(" }")13808-
return tmp13809-
end1381013789
return "sp_IntArray_length(" + rc + ")"1381113790
end1381213791
if mname == "min_by"@@ -13995,27 +13974,6 @@
1399513974
end1399613975
end1399713976
if mname == "count"13998-
if @nd_block[nid] >= 013999-
blk = @nd_block[nid]14000-
bp = get_block_param(nid, 0)14001-
declare_var(bp, "string")14002-
tmp = new_temp14003-
itmp = new_temp14004-
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 >= 014010-
bs = get_stmts(bbody)14011-
if bs.length > 014012-
bexpr = compile_expr(bs.last)14013-
end14014-
end14015-
emit(" if (" + bexpr + ") " + tmp + "++;")14016-
emit(" }")14017-
return tmp14018-
end1401913977
return "sp_StrArray_length(" + rc + ")"1402013978
end1402113979
end