]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 2425: Don't reload initialization files when processing multiple files
authorDavid Kastrup <dak@gnu.org>
Wed, 21 Mar 2012 18:57:46 +0000 (19:57 +0100)
committerDavid Kastrup <dak@gnu.org>
Mon, 26 Mar 2012 08:15:24 +0000 (10:15 +0200)
This significantly speeds up processing of multiple files per session,
but has some more potential for bleedover between files.

Bleedover can occur when data structures set up by init.ly (and the
loaded files) in the parser module before calling the main file are
modified in-place.

init.ly caters for the known cases: some hash tables modified by user
commands are cleared at the start of a new pass, and output
definitions are cloned rather than reused from the first load of
init.ly.

ly/init.ly
scm/lily.scm

index 6546ed422aa676bffd633bacf013b9c8e7086e9b..684ea14e454731243e8febedfaf292ca3182e304 100644 (file)
@@ -6,8 +6,41 @@
 
 \version "2.15.18"
 
-\include "declarations-init.ly"
+#(if (not (pair? lilypond-declarations))
+     (ly:parser-include-string parser
+                              "\\include \"declarations-init.ly\""))
 
+%% We need to save the variables of the current module along with
+%% their values: functions defined in the module might refer to the
+%% variables
+
+#(if lilypond-declarations
+     (if (pair? lilypond-declarations)
+        (begin
+          (for-each
+           (lambda (p)
+             (let ((var (cadr p))
+                   (val (cddr p)))
+               (variable-set! var
+                              (if (ly:output-def? val)
+                                  (ly:output-def-clone val)
+                                  val))
+               (module-add! (current-module) (car p) var)))
+           lilypond-declarations)
+          (note-names-language parser default-language))
+        (module-for-each
+         (lambda (s v)
+           (let ((val (variable-ref v)))
+             (if (not (ly:lily-parser? val))
+                 (set! lilypond-declarations
+                       (cons
+                        (cons*
+                         s v
+                         (if (ly:output-def? val)
+                             (ly:output-def-clone val)
+                             val))
+                        lilypond-declarations)))))
+         (current-module))))
 
 #(ly:set-option 'old-relative #f)
 #(define toplevel-scores (list))
 #(define expect-error #f)
 #(define output-empty-score-list #f)
 #(define output-suffix #f)
+#(hash-clear! default-fret-table)
+#(hash-clear! chord-shape-table)
+#(hash-clear! musicQuotes)
+
 #(use-modules (scm clip-region))
+#(use-modules (srfi srfi-1))
 
 $(if (ly:get-option 'include-settings)
   (ly:parser-include-string parser
index 0c20c148b20a5ec56066379eaee887eeab20bf8b..64c403b0749432e55df286cae181876a3a1cebde 100644 (file)
@@ -845,6 +845,8 @@ PIDs or the number of the process."
         (dump-profile "lily-run-total" '(0 0) (profile-measurements)))
     failed))
 
+(define-public lilypond-declarations '())
+
 (define (lilypond-file handler file-name)
   (catch 'ly-file-failed
          (lambda () (ly:parse-file file-name))