summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2014-06-04 19:30:16 -0400
committerMark H Weaver <mhw@netris.org>2014-06-04 19:37:50 -0400
commit1ea8954814d124b995f2296bc6aec92adb566bc1 (patch)
treef57c1304160b7dbbb98034c044f3935571661160
parent2da97f1c7c0748509180308d9e6a817bc49172e7 (diff)
downloadguile-1ea8954814d124b995f2296bc6aec92adb566bc1.tar.gz
Avoid quadratic expansion time in 'and' and 'or' macros.
Fixes <http://bugs.gnu.org/17147>. Reported by David Kastrup <dak@gnu.org>. * module/ice-9/boot-9.scm (and, or): Use dotted tail instead of ellipsis in patterns.
-rw-r--r--module/ice-9/boot-9.scm10
1 files changed, 5 insertions, 5 deletions
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 42d7d7837..c6d4be111 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -1,8 +1,6 @@
;;; -*- mode: scheme; coding: utf-8; -*-
-;;;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;;;; 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
-;;;; Free Software Foundation, Inc.
+;;;; Copyright (C) 1995-2014 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
@@ -409,13 +407,15 @@ If there is no handler at all, Guile prints an error and then exits."
(syntax-rules ()
((_) #t)
((_ x) x)
- ((_ x y ...) (if x (and y ...) #f))))
+ ;; Avoid ellipsis, which would lead to quadratic expansion time.
+ ((_ x . y) (if x (and . y) #f))))
(define-syntax or
(syntax-rules ()
((_) #f)
((_ x) x)
- ((_ x y ...) (let ((t x)) (if t t (or y ...))))))
+ ;; Avoid ellipsis, which would lead to quadratic expansion time.
+ ((_ x . y) (let ((t x)) (if t t (or . y))))))
(include-from-path "ice-9/quasisyntax")