[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/07: gexp: Micro-optimize sexp serialization.
From: |
Ludovic Courtès |
Subject: |
03/07: gexp: Micro-optimize sexp serialization. |
Date: |
Fri, 20 Nov 2015 22:39:00 +0000 |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 6f957731480a2b453d0fb71a9d009ee30e37fd8b
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 606bebe..c5f3d4c 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -412,6 +412,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)
@@ -493,7 +502,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 4c2ade2), Ludovic Courtès, 2015/11/20
- 01/07: gnu: bootstrap: Move 'use-modules' forms to the beginning of build expressions., Ludovic Courtès, 2015/11/20
- 03/07: gexp: Micro-optimize sexp serialization.,
Ludovic Courtès <=
- 04/07: monads: Micro-optimize 'foldm'., Ludovic Courtès, 2015/11/20
- 05/07: tests: Add 'test-assertm' to (guix tests)., Ludovic Courtès, 2015/11/20
- 06/07: packages: Turn 'bag->derivation' into a monadic procedure., Ludovic Courtès, 2015/11/20
- 07/07: store: Add a functional object cache and use it in 'lower-object'., Ludovic Courtès, 2015/11/20
- 02/07: build-system: Rewrite using gexps., Ludovic Courtès, 2015/11/20