wingo pushed a commit to branch master
in repository guile.
commit 7486806ba3981df0a862054054fee2f41731329f
Author: Andy Wingo <[email protected]>
Date: Fri Jan 5 15:18:16 2018 +0100
Improve compilation of make-vector without init
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Add
expansion for one-argument make-vector.
---
module/language/tree-il/primitives.scm | 11 +++++++++++
module/srfi/srfi-43.scm | 14 +++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/module/language/tree-il/primitives.scm
b/module/language/tree-il/primitives.scm
index 934b5c7..89bf48a 100644
--- a/module/language/tree-il/primitives.scm
+++ b/module/language/tree-il/primitives.scm
@@ -470,6 +470,17 @@
(x y) (logand x y)
(x y z ... last) (logand (logand x y . z) last))
+(hashq-set!
+ *primitive-expand-table*
+ 'make-vector
+ (match-lambda*
+ ((src len)
+ (make-primcall src 'make-vector (list len (make-const src *unspecified*))))
+ ((src len init)
+ (make-primcall src 'make-vector (list len init)))
+ ((src . args)
+ (make-call src (make-primitive-ref src 'make-vector) args))))
+
(define-primitive-expander caar (x) (car (car x)))
(define-primitive-expander cadr (x) (car (cdr x)))
(define-primitive-expander cdar (x) (cdr (car x)))
diff --git a/module/srfi/srfi-43.scm b/module/srfi/srfi-43.scm
index 153b0cb..e1bf19e 100644
--- a/module/srfi/srfi-43.scm
+++ b/module/srfi/srfi-43.scm
@@ -1,6 +1,6 @@
;;; srfi-43.scm -- SRFI 43 Vector library
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2018 Free Software Foundation, Inc.
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -41,10 +41,14 @@
(cond-expand-provide (current-module) '(srfi-43))
-(define (error-from who msg . args)
- (apply error
- (string-append (symbol->string who) ": " msg)
- args))
+(define-syntax error-from
+ (lambda (stx)
+ (syntax-case stx (quote)
+ ((_ 'who msg arg ...)
+ #`(error #,(string-append (symbol->string (syntax->datum #'who))
+ ": "
+ (syntax->datum #'msg))
+ arg ...)))))
(define-syntax-rule (assert-nonneg-exact-integer k who)
(unless (and (exact-integer? k)