cl-grep

Simple implementation of grep
Log | Files | Refs

commit 6eaa3635f00bb1b143ea149abc2fe18f8938a199
parent 93ae1116c6c4f7610bc3050f241422f7756b8d29
Author: ChanderG <[email protected]>
Date:   Thu,  4 Dec 2025 16:48:01 +0530

add some type declarations; NO PERF IMPROVEMENT

improving perf seems to be impossible like this

Diffstat:
Mgrep.lisp | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/grep.lisp b/grep.lisp @@ -53,7 +53,9 @@ ;; Search a line for all matches of our target ;; returns a list of positions in the line (defun search-line (line match-idx fmatch) + (declare (type fixnum fmatch)) (loop with res = (list fmatch) + ;; todo: of-type fixnum here leads to failure with curr = (+ fmatch (length *match*)) while (setf curr (sm:search-bmh8 match-idx line :start2 curr)) do @@ -67,7 +69,7 @@ (with-open-file (stream file) (let ((results (loop for line = (read-line stream nil :eof) - with i = 0 with fmatch = nil + with i of-type fixnum = 0 with fmatch = nil until (eq line :eof) do (incf i) ;; search for location of first match @@ -93,6 +95,7 @@ (defun result-printer () (let ((bufstream (make-string-output-stream)) (count 0)) + (declare (type fixnum count)) (loop (handler-case (let ((task (lq:pop-queue *print-queue*)))