+(defvar *vff-position-hash* (make-hash-table :size 100 :test 'eq))
+
+(defmacro vff (filename fieldname record)
+ (let ((pos (gensym "POS-"))
+ (found (gensym "FOUND-"))
+ (key (kmrcl:ensure-keyword (concatenate 'string filename "^" fieldname))))
+ `(locally (declare (optimize (speed 3) (safety 0)))
+ (multiple-value-bind (,pos ,found) (gethash ,key *vff-position-hash*)
+ (declare (ignore ,found))
+ (if ,pos
+ (locally (declare (type (integer 0 100000) ,pos))
+ (nth ,pos ,record))
+ (let ((,pos (position-field-file ,filename ,fieldname)))
+ (unless ,pos
+ (error "Did not find fieldname ~A in filename ~A." ,fieldname ,filename))
+ (locally (declare (type (integer 0 100000) ,pos))
+ (setf (gethash ,key *vff-position-hash*) ,pos)
+ (nth ,pos ,record))))))))
+