civodul pushed a commit to branch wip-build-systems-gexp in repository guix.
commit 085c1f34e7b856cdbce621da953f3b498e0a95f4 Author: Ludovic Courtès <[email protected]> Date: Sat Mar 28 21:44:01 2015 +0100 gexp: Micro-optimize sexp serialization. * guix/gexp.scm (sexp->string): New procedure. (gexp->derivation): Use it instead of 'object->string'. --- guix/gexp.scm | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/guix/gexp.scm b/guix/gexp.scm index 418a9ff..6acd04d 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -321,6 +321,15 @@ names and file names suitable for the #:allowed-references argument to (lambda (system) ((force proc) system)))) +(define (sexp->string sexp) + "Like 'object->string', but deterministic and slightly faster." + ;; Explicitly use UTF-8 for determinism, and also because UTF-8 output is + ;; faster. + (with-fluids ((%default-port-encoding "UTF-8")) + (call-with-output-string + (lambda (port) + (write sexp port))))) + (define* (gexp->derivation name exp #:key system (target 'current) @@ -402,7 +411,7 @@ The other arguments are as for 'derivation'." #:system system #:target target)) (builder (text-file script-name - (object->string sexp))) + (sexp->string sexp))) (modules (if (pair? %modules) (imported-modules %modules #:system system
