[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/29: gexp: Micro-optimize sexp serialization.
From: |
guix-commits |
Subject: |
05/29: gexp: Micro-optimize sexp serialization. |
Date: |
Mon, 8 Mar 2021 06:24:48 -0500 (EST) |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 7890cce22341ff4b07aaea4416de906c45d43c4c
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: 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 | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 2735d25..04b5ce1 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès
<ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès
<ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -941,6 +941,15 @@ second element is the derivation to compile them."
modules
system extensions guile deprecation-warnings module-path))
+(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* (lower-gexp exp
#:key
(module-path %load-path)
@@ -1159,7 +1168,7 @@ The other arguments are as for 'derivation'."
(return #f)))
(guile -> (lowered-gexp-guile lowered))
(builder (text-file script-name
- (object->string
+ (sexp->string
(lowered-gexp-sexp lowered)))))
(mbegin %store-monad
(set-grafting graft?) ;restore the initial setting
- 02/29: store: Micro-optimize object cache lookup., (continued)
- 02/29: store: Micro-optimize object cache lookup., guix-commits, 2021/03/08
- 28/29: grafts: Add 'without-grafting'., guix-commits, 2021/03/08
- 29/29: gexp: Allowed/disallowed references and graphs never refer to grafted inputs., guix-commits, 2021/03/08
- 14/29: build-system: Rewrite using gexps., guix-commits, 2021/03/08
- 15/29: packages: Turn 'bag->derivation' into a monadic procedure., guix-commits, 2021/03/08
- 16/29: packages: Simplify patch instantiation., guix-commits, 2021/03/08
- 25/29: tests: Refer to '%derivation-cache' in the right module., guix-commits, 2021/03/08
- 26/29: packages: 'expand-input' accepts any file-like object., guix-commits, 2021/03/08
- 17/29: packages: Core procedures are written in monadic style., guix-commits, 2021/03/08
- 19/29: gexp: Add 'sexp->gexp'., guix-commits, 2021/03/08
- 05/29: gexp: Micro-optimize sexp serialization.,
guix-commits <=
- 12/29: gexp: Add 'with-build-variables'., guix-commits, 2021/03/08
- 18/29: packages: Default origin 'patch-flags' is a gexp., guix-commits, 2021/03/08
- 22/29: gexp: Honor #:target in 'compiled-modules'., guix-commits, 2021/03/08
- 23/29: packages: '%standard-patch-inputs' is not influenced by '%current-target-system'., guix-commits, 2021/03/08
- 24/29: download: 'url-fetch/tarbomb' and 'url-fetch/zipbomb' refer to native tools., guix-commits, 2021/03/08
- 27/29: packages: Call 'bag-grafts' only on the tip of the package graph., guix-commits, 2021/03/08