From 5ef6b01420fe68f40c266cec62c5b4a7931420f1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 17 Jun 2019 06:54:47 -0700 Subject: carray-sub: improved accessor. * share/txr/stdlib/ffi.tl (carray-sub): We use defset to define a carray-sub place that updates via carray-replace, rather than using a place macro to defer to the generic sub accessor. This results in a more efficient implementation. This new accessor doesn't require the carray argument to be a place; unlike sub, it doesn't have to capture the return value of carray-replace and store it back into the carray variable. * txr.1: Updated doc. --- share/txr/stdlib/ffi.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share') diff --git a/share/txr/stdlib/ffi.tl b/share/txr/stdlib/ffi.tl index ed8ad06d..6bbd43a9 100644 --- a/share/txr/stdlib/ffi.tl +++ b/share/txr/stdlib/ffi.tl @@ -145,8 +145,8 @@ (define-accessor carray-ref carray-refset) -(define-place-macro carray-sub (carray : (from 0) (to t)) - ^(sub ,carray ,from ,to)) +(defset carray-sub (carray : (from 0) (to t)) items + ^(progn (carray-replace ,carray ,items ,from ,to) ,items)) (defmacro znew (type . pairs) (if (oddp (length pairs)) -- cgit v1.2.3