From 032c19a4138ba9258e54e8d748db1e517900a899 Mon Sep 17 00:00:00 2001 From: ketmar Date: Thu, 2 Nov 2023 15:56:44 +0000 Subject: [PATCH] urasm: added file info cache (doesn't do much, but why not ;-) FossilOrigin-Name: e2b77c59657b956f5e51857f5436fb23cd84dbf573ac09c9f96502a1f6126c2a --- urflibs/urasm/labels.f | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/urflibs/urasm/labels.f b/urflibs/urasm/labels.f index b89f995..9281209 100644 --- a/urflibs/urasm/labels.f +++ b/urflibs/urasm/labels.f @@ -18,6 +18,8 @@ vocab-if-none (asm-labels) vocab-if-none asm-labels also-defs: asm-labels +$DEFINE URASM-LABEL-MAN-CACHE-LAST-FILE-INFO + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; label types @@ -48,6 +50,10 @@ define-accessors file-info end-accessors 0 value file-info-head +$IF $URASM-LABEL-MAN-CACHE-LAST-FILE-INFO +;; cached "last used" file info, because most of the time that's what we'll hit +0 value file-info-last +$ENDIF : file-info-init-append ( finfo -- ) 0 (include-file-id) over file-info->id! @@ -63,11 +69,24 @@ end-accessors ;; return FileInfo for the current source file ;; will reuse an existing one, or create a new one if required : curr-file-info ( -- file-info ) - file-info-head begin ?dup while + $IF $URASM-LABEL-MAN-CACHE-LAST-FILE-INFO + file-info-last ?dup if dup file-info->id@ 0 (include-file-id) = if exit endif + drop endif + $ENDIF + file-info-head begin ?dup while + dup file-info->id@ 0 (include-file-id) = if + $IF $URASM-LABEL-MAN-CACHE-LAST-FILE-INFO + dup to file-info-last + $ENDIF + exit + endif file-info->next@ repeat ;; not found, want a new struct file-info-size n-allot dup file-info-init-append + $IF $URASM-LABEL-MAN-CACHE-LAST-FILE-INFO + dup to file-info-last + $ENDIF ; -- 2.11.4.GIT