Commit 12c30d22
12c30d221adcMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 5 files · +2 added · ~3 modified
Description
Array literals [1,2,3] now compile to IntArray, ["a","b"] to StrArray
Homogeneous integer array literals produce sp_IntArray instead of sp_RbArray, enabling all IntArray methods (sort, min, max, etc.) without polymorphic boxing. String arrays similarly produce sp_StrArray. Mixed-type arrays still use sp_RbArray as before.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 12c30d221adc
- Parent
- 6bfc4fe5bf20
examples/bm_array_lit.rbaddedView file
1+
# Test array literals as IntArray/StrArray2+
3+
# Integer array literal4+
arr = [5, 3, 8, 1, 4]5+
puts arr.length # 56+
puts arr[0] # 57+
puts arr.sort[0] # 18+
puts arr.sum # 219+
puts arr.min # 110+
puts arr.max # 811+
12+
# String array literal13+
words = ["hello", "world", "foo"]14+
puts words.length # 315+
puts words[0] # hello16+
puts words.join(", ") # hello, world, foo17+
18+
# Empty array19+
empty = []20+
empty.push(42)21+
puts empty.length # 122+
puts empty[0] # 4223+
24+
puts "done"examples/bm_fileopen.rbaddedView file
Loading diff…
src/codegen.cmodifiedView file
Loading diff…
src/expr.cmodifiedView file
Loading diff…
src/type.cmodifiedView file
Loading diff…