Liste des Groupes | Revenir à cl forth |
On 11/06/2025 11:54 pm, LIT wrote:It's slightly faster than the original on 4tH:Let's find out the difference between mySame using stack ops:
and "Mark Twain" 's approach to the solution
of "parsing 'time string' task". For simplicity
I'll do everything using DX Forth.
>
My solution is:
>
VARIABLE C6
VARIABLE C1
>
: TIMESTRSCAN ( addr count -- d )
1 C6 ! 1 C1 !
>R >R 0 0 R> R>
OVER + 1-
DO
I C@ DUP 58 =
IF
DROP
C6 @ 60 * C6 !
1 C1 !
ELSE
48 - C1 @ * C6 @ M* D+
10 C1 !
THEN
-1 +LOOP
;
: TIMESTRSCAN2 ( addr count -- d )
>R >R 0 0 1 1 ( C6 C1) R> R>
OVER + 1- DO
I C@ DUP 58 = IF DROP
DROP 60 * ( C6) 1 ( C1)
ELSE
48 - * OVER ( C6) >R UM* D+ R> 10 ( C1)
THEN
-1 +LOOP 2DROP ;
12% faster and 20% smaller by my measurement.
Les messages affichés proviennent d'usenet.