Permalink
Browse files

hold the compiler's hand a bit

  Enough to get rid of run-time type dispatch for DEFDECODER :UTF-8.
  • Loading branch information...
1 parent a2d7d6b commit 2f4e3b3f07e4fa3827505d4a02e0e616395faccd @nikodemus committed Apr 21, 2012
Showing with 15 additions and 15 deletions.
  1. +7 −7 enc-utf8.lisp
  2. +8 −8 encoding.lisp
View
@@ -116,17 +116,17 @@
(t
(with-byte (byte3 (byte byte2))
((and (= byte #xe0) (< byte2 #xa0))
- ;; overlong
+ ;; overlong
(utf-8-error byte byte2 byte3))
((< byte #xf0)
- ;; 3 bytes
+ ;; 3 bytes
(logior (ash (logand #x0f byte) 12)
(ash (logand #x3f byte2) 6)
(logand #x3f byte3)))
(t
(with-byte (byte4 (byte byte2 byte3))
((and (= byte #xf0) (< byte2 #x90))
- ;; overlong
+ ;; overlong
(utf-8-error byte byte2 byte3 byte4))
((< byte #xf4)
(if (or (> byte #xf4) (and (= byte #xf4) (> byte2 #x8f)))
@@ -141,18 +141,18 @@
(t
(with-byte (byte5 (byte byte2 byte3 byte4))
((and (= byte #xf8) (< byte2 #x88))
- ;; overlong
+ ;; overlong
(utf-8-error byte byte2 byte3 byte4 byte5))
((< byte #xfc)
- ;; character out of range
+ ;; character out of range
(utf-8-error byte byte2 byte3 byte4 byte5))
(t
(with-byte (byte6 (byte byte2 byte3 byte4 byte5))
((and (= byte #xfc) (< byte2 #x84))
- ;; overlong
+ ;; overlong
(utf-8-error byte byte2 byte3 byte4 byte5 byte6))
(t
- ;; character out of range
+ ;; character out of range
(utf-8-error byte byte2 byte3 byte4 byte5 byte6))))))))))))))))
skip))
View
@@ -254,12 +254,10 @@ The defined function should return as multiple values the number of octets decod
the number of characters they decoded into, and a tertiary value that is true iff
any remaining bytes in the given input are too short to consitute a valid code sequence.
-Use macro SET-CHAR-CODE in the body to write to SRC."
- (with-unique-names (eol-mark eol)
+Use macro SET-CHAR-CODE in the body to write to DST."
+ (with-unique-names (eol-mark eol typed-dst)
(let ((name (symbolicate encoding "-DECODER")))
`(progn
- ;; FIXME: Split into base-string and character string versions for speed.
- ;; the caller is responsible for making sure we don't have a non-simple thing.
(defun ,name (,src ,src-offset ,dst ,dst-offset ,length ,limit ,eol)
(declare (string ,dst)
(index ,src-offset ,dst-offset ,length ,limit)
@@ -268,15 +266,17 @@ Use macro SET-CHAR-CODE in the body to write to SRC."
(declare (system-area-pointer ,src))
(etypecase ,dst
((simple-array character (*))
- (decode-to-string ,src ,dst))
+ (locally (declare (type (simple-array character (*)) ,dst))
+ (decode-to-string ,src ,dst)))
((simple-array base-char (*))
- (decode-to-string ,src ,dst))))
- (decode-to-string (,src ,dst)
+ (locally (declare (type (simple-array base-char (*)) ,dst))
+ (decode-to-string ,src ,dst)))))
+ (decode-to-string (,src ,typed-dst)
(declare (muffle-conditions code-deletion-note))
(macrolet ((using-eol (eol-style)
`(symbol-macrolet ((set-char-code-eol-style ,eol-style)
(set-char-code-eol-mark ,',eol-mark)
- (set-char-code-dst ,',dst)
+ (set-char-code-dst ,',typed-dst)
(set-char-code-dst-offset ,',dst-offset))
,@',body)))
(let ((,eol-mark 1))

0 comments on commit 2f4e3b3

Please sign in to comment.