Commit f93d1966
f93d1966ac77Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · ~3 modified
Description
String#setbyte/getbyte, String#dup heap copy, Array#zip block param inference
- Add String#setbyte dispatch -> sp_str_setbyte
- Add String#getbyte runtime helper and dispatch
- Fix String#dup/clone to create heap copies via sp_str_dup_external
- Add sp_str_getbyte NULL-safe helper
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- f93d1966ac77
- Parent
- 41412c72b60a
lib/sp_runtime.hmodifiedView file
@@ -1834,6 +1834,14 @@
18341834
0xff -> rodata literal (frozen -> FrozenError)18351835
other -> FFI / unknown provenance, treated as frozen18361836
Returns the byte value (CRuby setbyte return). */1837+
static inline mrb_int sp_str_getbyte(const char *s, mrb_int i) {1838+
if (!s) return 0;1839+
mrb_int bl = (mrb_int)sp_str_byte_len(s);1840+
if (i < 0) i += bl;1841+
if (i < 0 || i >= bl) return 0;1842+
return (mrb_int)(unsigned char)s[i];1843+
}1844+
18371845
static inline mrb_int sp_str_setbyte(const char *s, mrb_int i, mrb_int v) {18381846
if (!s) {18391847
sp_raise_cls("FrozenError", "can't modify frozen String");src/analyze.cmodifiedView file
Loading diff…
src/codegen.cmodifiedView file
Loading diff…