[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/07: gexp: Micro-optimize sexp serialization.
From: |
Ludovic Courtès |
Subject: |
07/07: gexp: Micro-optimize sexp serialization. |
Date: |
Sat, 28 Mar 2015 21:10:55 +0000 |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 27044cb55934c29af43472fc0728409f0f3036e4
Author: Ludovic Courtès <address@hidden>
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 ddf74c4..172769a 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -257,6 +257,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)
@@ -335,7 +344,7 @@ The other arguments are as for 'derivation'."
#:system system
#:target target))
(builder (text-file (string-append name "-builder")
- (object->string sexp)))
+ (sexp->string sexp)))
(modules (if (pair? %modules)
(imported-modules %modules
#:system system
- branch wip-build-systems-gexp created (now 27044cb), Ludovic Courtès, 2015/03/28
- 01/07: doc: Update gexp wrt. extensibility., Ludovic Courtès, 2015/03/28
- 03/07: gnu: bootstrap: Move 'use-modules' forms to the beginning of build expressions., Ludovic Courtès, 2015/03/28
- 05/07: packages: Refer to the native tools when handling sources and downloads., Ludovic Courtès, 2015/03/28
- 07/07: gexp: Micro-optimize sexp serialization.,
Ludovic Courtès <=
- 04/07: gexp: Slightly simplify 'lower-inputs'., Ludovic Courtès, 2015/03/28
- 02/07: gexp: Add 'local-file'., Ludovic Courtès, 2015/03/28
- 06/07: build-system: Rewrite using gexps., Ludovic Courtès, 2015/03/28