fix(fun/wcl): Use 'eql' for byte comparisons

The fact that this works is just an implementation-specific detail. In
theory, 'eq' will only compare object instance equality and not value.

Thanks to /u/patrec from HN for pointing this out.
This commit is contained in:
Vincent Ambo 2020-01-29 00:03:50 +00:00
parent 0001dfd7f6
commit b0b52255bd

View file

@ -12,7 +12,7 @@
(iter
(for byte in-stream file-stream using #'read-byte)
(for previous-byte previous byte)
(for is-newline = (eq newline byte))
(for is-newline = (eql newline byte))
;; Count each byte
(sum 1 into bytes)
@ -22,12 +22,12 @@
;; Count every "word", unless the preceding character already
;; was a space or we are at the beginning of the file.
(when (or (eq space previous-byte)
(eq newline previous-byte)
(when (or (eql space previous-byte)
(eql newline previous-byte)
(not previous-byte))
(next-iteration))
(counting (or is-newline (eq space byte))
(counting (or is-newline (eql space byte))
into words)
(declare (fixnum bytes newlines words))