commit a6df71856fbf9c16777f10fb540e676b4f968158
parent b0e28dcbef21192ae5d2b93287d2c245857a2f01
Author: ChanderG <[email protected]>
Date: Tue, 2 Dec 2025 20:19:22 +0530
convert to bmh impl; approx. 20% savings?
some initial tests show ~20% savings, but we expect a lot more
maybe the issue is with the stdout
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/grep.lisp b/grep.lisp
@@ -6,13 +6,13 @@
(defun setup-tasks-mgmt ()
(setf *queue* (lq:make-queue)))
-(defun grep-file (file)
+(defun grep-file (file match-idx)
(lo "Grepping file: ~a" file)
(handler-case
(with-open-file (stream file)
(loop for line = (read-line stream nil :eof)
until (eq line :eof) collect
- (if (sm:string-contains-brute *match* line)
+ (if (sm:search-bmh8 match-idx line)
(format t "~a: ~a ~%" file line))))
(stream-error (stream)
(lo "Skipping binary file: ~a" file))
@@ -20,11 +20,12 @@
(lo "Unknown error: ~a when reading file ~a" c file))))
(defun process-task ()
- (loop
- (let ((task (lq:pop-queue *queue*)))
- (if (eq task :done)
- (return))
- (grep-file task))))
+ (let ((match-idx (sm:initialize-bmh8 *match*)))
+ (loop
+ (let ((task (lq:pop-queue *queue*)))
+ (if (eq task :done)
+ (return))
+ (grep-file task match-idx)))))
(defun queue-file (file)
(lo "Visiting file: ~a" file)