[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/16: gexp: Micro-optimize sexp serialization.
From: |
Ludovic Courtès |
Subject: |
03/16: gexp: Micro-optimize sexp serialization. |
Date: |
Wed, 28 Jun 2017 17:48:54 -0400 (EDT) |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 180446ebbdc774d596805bcd3981c0ba0f8e89f0
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 5c30998..b22d7fb 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -537,6 +537,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)
@@ -623,7 +632,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 6ce5f33), Ludovic Courtès, 2017/06/28
- 08/16: packages: Simplify patch instantiation., Ludovic Courtès, 2017/06/28
- 03/16: gexp: Micro-optimize sexp serialization.,
Ludovic Courtès <=
- 04/16: tests: Add 'test-assertm' to (guix tests)., Ludovic Courtès, 2017/06/28
- 13/16: utils: Memoize 'absolute-dirname'., Ludovic Courtès, 2017/06/28
- 12/16: gexp: 'local-file' calls 'canonicalize-path' only in rare cases., Ludovic Courtès, 2017/06/28
- 14/16: download: 'built-in-builders*' relies on the functional cache., Ludovic Courtès, 2017/06/28
- 01/16: gnu: bootstrap: Move 'use-modules' forms to the beginning of build expressions., Ludovic Courtès, 2017/06/28
- 15/16: store: Add 'GUIX_PROFILING' support for the object cache., Ludovic Courtès, 2017/06/28
- 09/16: Use 'mapm' instead of 'sequence' + 'map'., Ludovic Courtès, 2017/06/28
- 05/16: packages: Turn 'bag->derivation' into a monadic procedure., Ludovic Courtès, 2017/06/28
- 11/16: packages: Turn 'cache!' into a single-value-return cache., Ludovic Courtès, 2017/06/28
- 06/16: store: Add a functional object cache and use it in 'lower-object'., Ludovic Courtès, 2017/06/28