diff --git a/src/builtins/md2.c b/src/builtins/md2.c index 6ba2dd3e..ae901bff 100644 --- a/src/builtins/md2.c +++ b/src/builtins/md2.c @@ -59,26 +59,35 @@ B catch_c2(Md2D* d, B w, B x) { return c2(d->f, w,x); } extern B rt_undo; void repeat_bounds(i64* bound, B g) { // doesn't consume + #define UPD_BOUNDS(I) ({ i64 i_ = (I); if (i_bound[1]) bound[1] = i_; }) if (isArr(g)) { - SGetU(g) usz ia = IA(g); - for (usz i = 0; i < ia; i++) repeat_bounds(bound, GetU(g, i)); + u8 xe = TI(g,elType); + if (elNum(xe)) { + incG(g); + if (xebound[1]) bound[1] = i; + UPD_BOUNDS(o2i64(g)); } else thrM("⍟: 𝔾 contained a non-number atom"); } -B repeat_replace(B g, B* q) { // doesn't consume - if (isArr(g)) { - SGetU(g) - usz ia = IA(g); - M_HARR(r, ia); - for (usz i = 0; i < ia; i++) HARR_ADD(r, i, repeat_replace(GetU(g,i), q)); - return HARR_FC(r, g); - } else { - return inc(q[o2i64G(g)]); - } +B repeat_replaceR(B g, B* q); +FORCE_INLINE B repeat_replace(B g, B* q) { // doesn't consume + if (isArr(g)) return repeat_replaceR(g, q); + else return inc(q[o2i64G(g)]); +} +NOINLINE B repeat_replaceR(B g, B* q) { + SGetU(g) + usz ia = IA(g); + M_HARR(r, ia); + for (usz i = 0; i < ia; i++) HARR_ADD(r, i, repeat_replace(GetU(g,i), q)); + return HARR_FC(r, g); } #define REPEAT_T(CN, END, ...) \ B g = CN(d->g, __VA_ARGS__ inc(x)); \