me
/
guix
Archived
1
0
Fork 0

packages: ‘define-public’ replacement calls ‘module-export!’ directly.

This reduces code bloat and loading overhead for package modules, which
use ‘define-public’ extensively.

* guix/packages.scm (define-public*): Use ‘define’ followed by
‘module-export!’ directly instead of ‘define-public’.

Change-Id: I7f56d46b391c1e3eeeb0b9a08a9d34b5de341245
master
Ludovic Courtès 2024-04-13 17:58:39 +02:00
parent c14b8636fb
commit 76127069e0
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 17 additions and 5 deletions

View File

@ -481,7 +481,8 @@ one-indexed line numbers."
(define-syntax define-public* (define-syntax define-public*
(lambda (s) (lambda (s)
"Like 'define-public' but set 'current-definition-location' for the "Like 'define-public' but set 'current-definition-location' for the
lexical scope of its body." lexical scope of its body. (This also disables notification of \"module
observers\", but this is unlikely to affect anyone.)"
(define location (define location
(match (syntax-source s) (match (syntax-source s)
(#f #f) (#f #f)
@ -498,10 +499,21 @@ lexical scope of its body."
(syntax-case s () (syntax-case s ()
((_ prototype body ...) ((_ prototype body ...)
#`(define-public prototype (with-syntax ((name (syntax-case #'prototype ()
((id _ ...) #'id)
(id #'id))))
#`(begin
(define prototype
(syntax-parameterize ((current-definition-location (syntax-parameterize ((current-definition-location
(lambda (s) #,location))) (lambda (s) #,location)))
body ...)))))) body ...))
;; Note: Use 'module-export!' directly to avoid emitting a
;; 'call-with-deferred-observers' call for each 'define-public*'
;; instance, which is not only pointless but also contributes to
;; code bloat and to load-time overhead in package modules.
(eval-when (expand load eval)
(module-export! (current-module) '(name)))))))))
(define-syntax validate-texinfo (define-syntax validate-texinfo
(let ((validate? (getenv "GUIX_UNINSTALLED"))) (let ((validate? (getenv "GUIX_UNINSTALLED")))