[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/08: gexp: Micro-optimize sexp serialization.
From: |
David Craven |
Subject: |
03/08: gexp: Micro-optimize sexp serialization. |
Date: |
Fri, 6 Jan 2017 11:16:03 +0000 (UTC) |
dvc pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 77b596c86d50a961865cb8ed76246896914d15bd
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 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 36a8d4d..8e4581c 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -512,6 +512,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)
@@ -598,7 +607,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
- branch wip-build-systems-gexp created (now 58fee7f), David Craven, 2017/01/06
- 03/08: gexp: Micro-optimize sexp serialization.,
David Craven <=
- 05/08: tests: Add 'test-assertm' to (guix tests)., David Craven, 2017/01/06
- 01/08: gnu: bootstrap: Move 'use-modules' forms to the beginning of build expressions., David Craven, 2017/01/06
- 04/08: monads: Micro-optimize 'foldm'., David Craven, 2017/01/06
- 06/08: packages: Turn 'bag->derivation' into a monadic procedure., David Craven, 2017/01/06
- 08/08: DRAFT gexp: Handle list conversion to <gexp-input> in the expanded code., David Craven, 2017/01/06
- 07/08: store: Add a functional object cache and use it in 'lower-object'., David Craven, 2017/01/06
- 02/08: build-system: Rewrite using gexps., David Craven, 2017/01/06