diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2015-03-28 21:44:01 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2021-02-23 15:24:48 +0100 |
| commit | bde7929bd06196ed84f96d08676ee43da4685975 (patch) | |
| tree | 5ed74de15d7a1fd8b3a2180aa99e9e6ccc465a4b | |
| parent | 70b33d8898031d0f8623922762442f4abf6adcc4 (diff) | |
gexp: Micro-optimize sexp serialization.
* guix/gexp.scm (sexp->string): New procedure.
(gexp->derivation): Use it instead of 'object->string'.
| -rw-r--r-- | guix/gexp.scm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm index 764c89a1873..8dd824c5129 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> | 3 | ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> |
| 4 | ;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org> | 4 | ;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org> |
| 5 | ;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com> | 5 | ;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com> |
| @@ -941,6 +941,15 @@ second element is the derivation to compile them." | |||
| 941 | modules | 941 | modules |
| 942 | system extensions guile deprecation-warnings module-path)) | 942 | system extensions guile deprecation-warnings module-path)) |
| 943 | 943 | ||
| 944 | (define (sexp->string sexp) | ||
| 945 | "Like 'object->string', but deterministic and slightly faster." | ||
| 946 | ;; Explicitly use UTF-8 for determinism, and also because UTF-8 output is | ||
| 947 | ;; faster. | ||
| 948 | (with-fluids ((%default-port-encoding "UTF-8")) | ||
| 949 | (call-with-output-string | ||
| 950 | (lambda (port) | ||
| 951 | (write sexp port))))) | ||
| 952 | |||
| 944 | (define* (lower-gexp exp | 953 | (define* (lower-gexp exp |
| 945 | #:key | 954 | #:key |
| 946 | (module-path %load-path) | 955 | (module-path %load-path) |
| @@ -1159,7 +1168,7 @@ The other arguments are as for 'derivation'." | |||
| 1159 | (return #f))) | 1168 | (return #f))) |
| 1160 | (guile -> (lowered-gexp-guile lowered)) | 1169 | (guile -> (lowered-gexp-guile lowered)) |
| 1161 | (builder (text-file script-name | 1170 | (builder (text-file script-name |
| 1162 | (object->string | 1171 | (sexp->string |
| 1163 | (lowered-gexp-sexp lowered))))) | 1172 | (lowered-gexp-sexp lowered))))) |
| 1164 | (mbegin %store-monad | 1173 | (mbegin %store-monad |
| 1165 | (set-grafting graft?) ;restore the initial setting | 1174 | (set-grafting graft?) ;restore the initial setting |
