r11480: make field position lookup more efficient by computing 'eq key at compile...
[umlisp.git] / parse-rrf.lisp
index 8a1bb1ebd47f116fcd5cdc7710a50d9634cdf83e..e8e919de245a0e34da419ac546bf35b7072cfc9c 100644 (file)
@@ -187,13 +187,14 @@ used in the United States. We create a new scale (SRLUS) where SRL to SRLUS mapp
   '(("KCON" "SELECT CUI,STR FROM MRCONSO WHERE STT='PF' AND TS='P' AND ISPREF='Y' AND LAT='ENG'"))
   "Custom tables to create")
 
-(declaim (inline vff))
-(defun vff (filename fieldname record)
-  (let ((pos (position-field-file filename fieldname)))
-    (unless pos
-      (error "Did not find fieldname ~A in filename ~A." fieldname filename))
-    (locally (declare (fixnum pos))
-      (nth pos record))))
+(defmacro vff (filename fieldname record)
+  (let ((pos (gensym "POS-"))
+        (key (kmrcl:ensure-keyword (concatenate 'string filename "^" fieldname))))
+    `(let ((,pos (position-field-file ,filename ,fieldname ,key)))
+      (unless ,pos
+        (error "Did not find fieldname ~A in filename ~A." ,fieldname ,filename))
+      (locally (declare (type (integer 0 100000) ,pos))
+        (nth ,pos ,record)))))
 
 (defparameter +custom-cols+
     '(#+nil ("MRCONSO.RRF" "KPFSTR" "TEXT"