From 68e76a9876a736f97c48469c546d10fdc20d4374 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Tue, 6 Sep 2011 02:07:01 -0600 Subject: [PATCH] =?UTF-8?q?syntax/parse:=20speed=20up=20free-identifier=3D?= =?UTF-8?q?=3F/phases=20when=20phases=20are=20same?= --- collects/syntax/parse/private/runtime.rkt | 38 +++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/collects/syntax/parse/private/runtime.rkt b/collects/syntax/parse/private/runtime.rkt index d8beb8e6f0..07f8f02a9e 100644 --- a/collects/syntax/parse/private/runtime.rkt +++ b/collects/syntax/parse/private/runtime.rkt @@ -273,23 +273,27 @@ ;; that y has at phase-level y. ;; At least one of the identifiers MUST have a binding (module or lexical) (define (free-identifier=?/phases x phase-x y phase-y) - (let ([bx (identifier-binding x phase-x)] - [by (identifier-binding y phase-y)]) - (cond [(and (list? bx) (list? by)) - (let ([modx (module-path-index-resolve (first bx))] - [namex (second bx)] - [phasex (fifth bx)] - [mody (module-path-index-resolve (first by))] - [namey (second by)] - [phasey (fifth by)]) - (and (eq? modx mody) ;; resolved-module-paths are interned - (eq? namex namey) - (equal? phasex phasey)))] - [else - ;; Module is only way to get phase-shift; if not module-bound names, - ;; then only identifiers at same phase can refer to same binding. - (and (equal? phase-x phase-y) - (free-identifier=? x y phase-x))]))) + (cond [(eqv? phase-x phase-y) + (free-identifier=? x y phase-x)] + [else + (let ([bx (identifier-binding x phase-x)] + [by (identifier-binding y phase-y)]) + (cond [(and (pair? bx) (pair? by)) + (let ([mpix (first bx)] + [namex (second bx)] + [defphasex (fifth bx)] + [mpiy (first by)] + [namey (second by)] + [defphasey (fifth by)]) + (and (eq? namex namey) + ;; resolved-module-paths are interned + (eq? (module-path-index-resolve mpix) + (module-path-index-resolve mpiy)) + (eqv? defphasex defphasey)))] + [else + ;; Module is only way to get phase-shift; phases differ, so + ;; if not module-bound names, no way can refer to same binding. + #f]))])) ;; ----