Commit 54978f37

54978f375415Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified

Description

feat(codegen): support Array#sort (non-bang) on float_array

Mirrors the existing int_array sort arm: yields a fresh sorted copy by allocating a new sp_FloatArray, copying via the existing sp_FloatArray_replace, then sort_bang-ing it. The source array is left untouched.

Surfaced via optcarrot's p95-fps calculation (@fps_history.sort[(@fps_history.length * 0.05).floor]).

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

Details

Commit
54978f375415
Parent
3d99fa63c024

spinel_codegen.rbmodifiedView file

@@ -26565,6 +26565,14 @@
2656526565 if mname == "difference"
2656626566 return "sp_FloatArray_difference(" + rc + ", " + compile_arg0(nid) + ")"
2656726567 end
26568+ if mname == "sort"
26569+ # Non-bang: yield a fresh sorted copy. Mirror the
26570+ # `sp_FloatArray_shuffle` pattern (new + replace) so the
26571+ # source array is left untouched.
26572+ tmp = new_temp
26573+ emit(" sp_FloatArray *" + tmp + " = sp_FloatArray_new(); sp_FloatArray_replace(" + tmp + ", " + rc + "); sp_FloatArray_sort_bang(" + tmp + ");")
26574+ return tmp
26575+ end
2656826576 end
2656926577 if is_ptr_array_type(recv_type) == 1
2657026578 elem_type = ptr_array_elem_type(recv_type)