From ad8f189dba7367438755dda70cd641e796517986 Mon Sep 17 00:00:00 2001 From: crc Date: Wed, 15 May 2019 17:46:53 +0000 Subject: [PATCH] faster `times` FossilOrigin-Name: e037fc8bedf89920a5c03f9ee450be082e24042bf27e244804efa1f3f000845f --- ngaImage | Bin 40060 -> 40060 bytes source/interfaces/retro-image.c | 4 ++-- source/retro.forth | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ngaImage b/ngaImage index 15466290c1705658143a4f4544b780f79f17e613..a3dc782832de355ff3cda6e2c072135680800df2 100644 GIT binary patch delta 67 zcmeyfgXzx>rVTO5dW`H03@7$kw15sHO?G%FA@L1~~81~!JtUCL67H#aX; HzFq+UiL46? delta 67 zcmeyfgXzx>rVTO5dMpeK428?JtWdTnhz81Qa7^w}mSViMd8zXC F3IK^r3q}9{ diff --git a/source/interfaces/retro-image.c b/source/interfaces/retro-image.c index c60925a..b262b7b 100644 --- a/source/interfaces/retro-image.c +++ b/source/interfaces/retro-image.c @@ -113,8 +113,8 @@ int32_t ngaImage[] = { 1793,17237,17415,17457,201912,0,10,1,10,2,10,3,10,4,10,5, 2186,2208,147,119,104,105,108,101,0,1793,2220,2,2049,2076,4,25,3,1,2210,7, 10,1,2210,8,3,10,2199,2234,147,117,110,116,105,108,0,1793,2249,2,2049,2076, 4,1,-1,23,25,3,1,2236,7,10,1,2236,8,3,10,2225,2263,147,116,105, - 109,101,115,0,4,1793,2280,25,1,1,18,5,1,21,2049,2088,6,1,2266,7, - 10,1,2266,8,3,10,2254,2293,147,99,97,115,101,0,1793,2298,67502597,11,10,1, + 109,101,115,0,1793,2280,4,25,1,1,18,5,2,5,8,6,6,1,2266,7, + 10,1,2265,8,3,10,2254,2293,147,99,97,115,101,0,1793,2298,67502597,11,10,1, 2295,2049,2076,4,1793,2310,772,8,1,-1,10,1,2305,1793,2318,3,1,0,10,1, 2314,2049,67,25,6,3,3,10,2285,2337,147,115,58,99,97,115,101,0,1793,2343, 67502597,2049,96,10,1,2339,2049,2076,4,1793,2355,772,8,1,-1,10,1,2350,1793,2363, diff --git a/source/retro.forth b/source/retro.forth index 9997f18..084a3ac 100644 --- a/source/retro.forth +++ b/source/retro.forth @@ -425,9 +425,14 @@ Execute quote until quote returns a non-zero flag. The `times` combinator runs a quote (n) times. +This is defined using inlined Nga machine code. It corresponds +to: + + repeat 0; #1 - push dup push call pop pop again + ~~~ :times (nq-) - swap [ repeat 0; #1 - push &call sip pop again ] call drop ; + [ swap repeat 0; #1 - push dup push call pop pop again ] call drop ; ~~~ `case` is a conditional combinator. It's actually pretty