Nice to see you here. I was just casually looking through the txr-libs there and just randomly spotted this, the CSV library, in a let form:
(fieldrx (regex-compile ;; using a regex object here messes with emacs syntax highlighting
"([^,\"\']*(\"([^\"]|\\\\\")*\"|\'([^\']|\\\\\')*\'|)[^,\"\']*)+"))
I understand that here using the #/.../ regex literal object didn't look right in your Emacs, so you dynamically compiled from a string literal.But that now happens each time you call the function.
Lisp has your back here; we can hoist the compilation of the regex to load time using load-time:
(fieldrx (load-time (regex-compile "...RE...")))
load-time makes a difference in interpreted code, not just compiled files. Even in interpreted code, the regex-compile expression will be evaluated once only and then the cached value used: 1> (dotimes (i 5) (prinl "hi"))
"hi"
"hi"
"hi"
"hi"
"hi"
nil
2> (dotimes (i 5) (load-time (prinl "hi")))
"hi"
nil