[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/15: gexp: Micro-optimize sexp serialization.
From: |
guix-commits |
Subject: |
05/15: gexp: Micro-optimize sexp serialization. |
Date: |
Tue, 23 Feb 2021 08:34:00 -0500 (EST) |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 0ffe892e215b2db7800fa0ca7829ad241dd51ce7
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 620a86e..8e7e64b 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>
@@ -943,6 +943,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)
@@ -1161,7 +1170,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
- branch wip-build-systems-gexp created (now 0ffad81), guix-commits, 2021/02/23
- 03/15: packages: Simplify patch instantiation., guix-commits, 2021/02/23
- 05/15: gexp: Micro-optimize sexp serialization.,
guix-commits <=
- 09/15: gexp: Keep 'lower-inputs' private., guix-commits, 2021/02/23
- 06/15: squash! build-system: Rewrite using gexps., guix-commits, 2021/02/23
- 11/15: store: Object cache profiling shows the number of entries., guix-commits, 2021/02/23
- 10/15: gexp: Micro-optimize 'gexp->sexp' and 'lower-inputs'., guix-commits, 2021/02/23
- 08/15: gexp: 'gexp-inputs' returns both native and non-native inputs., guix-commits, 2021/02/23
- 14/15: store: Micro-optimize object cache lookup., guix-commits, 2021/02/23
- 04/15: packages: Core procedures are written in monadic style., guix-commits, 2021/02/23
- 02/15: packages: Turn 'bag->derivation' into a monadic procedure., guix-commits, 2021/02/23
- 13/15: grafts: Inline 'grafting?' and 'set-grafting'., guix-commits, 2021/02/23
- 07/15: gexp: 'gexp-inputs' returns a list of <gexp-input> records., guix-commits, 2021/02/23