伙计们,在 Common Lisp (SBCL) 中读取流的最快方法是什么?
对我来说,那是read-line。但是突然间我遇到了这个函数的性能问题——我应该在 1.5 秒内读取 10kk 个字符(1000 行,每个字符 10000 个字符),但 read-line 未能实现。Common Lisp 可以吗?它是否提供了 C 风格的scanf()函数来快速阅读?
谢谢!
更新。编码:
(defun split (string)
(let ((space-position (position #\Space string)))
(list
(subseq string 0 space-position)
(subseq string (+ space-position 1)))))
(defun solve (line)
(let ((nums (split line))
(first)
(second))
(setq first (parse-integer (car nums)))
(setq second (parse-integer (cadr nums)))
(* first second)))
(defun spoj()
(let ((N (read))
(line))
(dotimes (i N)
(setq line (read-line))
(format t "~d~%" (solve line))))))
(spoj)