[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Joke of the century.



The implementation of strings and bitvectors in Maclisp is a joke.
I brought up the NIL READer in maclisp to use as a Macro32 parser,
and the damn thing runs 138 times slower than it does in real VAX NIL.
If it were only 2 times slower it would be usable, but 138 times, 
that is absurd. For a 297 calls to +TYI there were 1297 calls to 
SI:CHECK-TYPER, 936 calls to PTR-TYPEP, 936 calls to BITSP,
828 calls to STR:CHARACTER-VALUEP, 828 calls to *:FIXNUM-TO-CHARACTER,
714 calls to CHAR-CODE, 645 calls to +INTERNAL-CHAR-N, 469 calls to
MEMQ on the arguments [BITS,(STRING VECTOR BITS LIST EXTEND)].
468 calls to SI:CHECK-SUBSEQUENCER, 468 to BITS-LENGTH, 468 to BIT,
360 to +INTERNAL-RPLACHAR-N, all for only 60 calls to READ-TOKEN.

There are just three functions that need to be fast, which make
up the inner loop of the finite state machine, I wonder if there
is a good way to get at the primitives to hand code them?

#+Maclisp
(defun si:inch-by-mask-into-string (stream bits string offset)
  ;; Maclisp conditionalized for using +TYI.
  (do ((n (string-length string))
       (c))
      ((= offset n) offset)
    (setq c (+tyi stream))
    (rplachar string offset (code-char c))
    (if (bit1p bits c)
	(return offset)
	(setq offset (1+ offset)))))

#+MACLISP
(defun si:inch-by-not-mask (stream bits)
  (do ((c))
      (())
    (setq c (+tyi stream))
    (cond ((= c -1) (*throw 'si:read-eof ()))
	  ((not (bit1p bits c))
	   (return (code-char c))))))

(defun si:translate-string-subseq (translations string offset length)
  (do ((j 0 (1+ j)))
      ((= j length) string)
    (rplachar string (+ j offset)
	      (char translations (char-code (char string (+ j offset)))))))


-gjc