shithub: orca

Download patch

ref: 7203f8443e5f71b78a406833bb9a6bebf886ac93
parent: ef070720c00ef69a75e21acb84290617e4f40ed9
author: cancel <cancel@cancel.fm>
date: Fri Nov 13 06:44:25 EST 2020

Fix J and Y to not grow when held by H

An oversight in the implementation of J and Y meant that the chain would
grow each frame, if there were at least two segments and the first
segment was locked by something like H. Example:

H
YY

This is not what we want. I've added a guard in the J and Y
implementations that checks if the glyph above (or for Y, to the left)
is an earlier part of the chain, and if it is, to return. This has the
downside of making long chains potentially having to enter the J code
repeatedly, only to end up doing nothing.

The STUN() in J and Y might no longer be worth it. It was used to
prevent further operators in the chain from running, but since we have a
guard now, the writes while looping might end up costing more time.

We don't have any good benchmark files set up right now, so we'll have
to test it in the future.

--- a/sim.c
+++ b/sim.c
@@ -498,9 +498,11 @@
 
 BEGIN_OPERATOR(jump)
   LOWERCASE_REQUIRES_BANG;
-  PORT(-1, 0, IN);
   Glyph g = PEEK(-1, 0);
-  for (Isz i = 1;; ++i) {
+  if (g == This_oper_char)
+    return;
+  PORT(-1, 0, IN);
+  for (Isz i = 1; i <= 256; ++i) {
     if (PEEK(i, 0) != This_oper_char) {
       PORT(i, 0, OUT);
       POKE(i, 0, g);
@@ -706,9 +708,11 @@
 
 BEGIN_OPERATOR(yump)
   LOWERCASE_REQUIRES_BANG;
-  PORT(0, -1, IN);
   Glyph g = PEEK(0, -1);
-  for (Isz i = 1;; ++i) {
+  if (g == This_oper_char)
+    return;
+  PORT(0, -1, IN);
+  for (Isz i = 1; i <= 256; ++i) {
     if (PEEK(0, i) != This_oper_char) {
       PORT(0, i, OUT);
       POKE(0, i, g);
--