,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2021-09-02 10:52:45 AntonErtl wrote: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#contribution-211 `------------------------------------------ ``` : cmove {: afrom ato u | u1 -- :} ato afrom - u u< if \ pattern replication case ato afrom - u over + to u1 begin afrom afrom 2 pick + 2 pick u1 over - min move 2* dup u u>= until drop else \ the usual non-pattern case ato afrom u move then ; ``` This is not as simple as copying byte by byte, but significantly more efficient (e.g., factor >10 for 32-bit VFX 4.71 with patterns of length 2) for both cases if MOVE is implemented efficiently. ,---------. | Replies | `---------´ ,------------------------------------------ | 2021-09-02 15:39:16 PeterFalth replies: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#reply-721 `------------------------------------------ For the usual non-pattern case should it not be afrom ato u move? ,------------------------------------------ | 2021-09-02 16:47:00 AntonErtl replies: | referenceImplementation - CMOVE implementation based on MOVE | see: https://forth-standard.org/standard/string/CMOVE#reply-722 `------------------------------------------ ``` : cmove {: afrom ato u | u1 -- :} ato afrom - u u< if \ pattern replication case ato afrom - u over + to u1 begin afrom afrom 2 pick + 2 pick u1 over - min move 2* dup u u>= until drop else \ the usual non-pattern case afrom ato u move then ; ``` This is not as simple as copying byte by byte, but significantly more efficient (e.g., factor >10 for 32-bit VFX 4.71 with patterns of length 2) for both cases if MOVE is implemented efficiently.