mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 17:27:33 +02:00
Use memq instead of member
We are looking up symbols so memq can be used instead, which is must faster at scale.
This commit is contained in:
parent
70b27ccd22
commit
9727e9f86c
1 changed files with 16 additions and 16 deletions
|
@ -45,16 +45,16 @@
|
||||||
(cons (cons cps-sym inline-sym) *udf-cps->inline*))
|
(cons (cons cps-sym inline-sym) *udf-cps->inline*))
|
||||||
(set! *udf-prims* (cons inline-sym *udf-prims*)))
|
(set! *udf-prims* (cons inline-sym *udf-prims*)))
|
||||||
(define (prim:udf? exp)
|
(define (prim:udf? exp)
|
||||||
(member exp *udf-prims*))
|
(memq exp *udf-prims*))
|
||||||
|
|
||||||
; prim? : exp -> boolean
|
; prim? : exp -> boolean
|
||||||
(define (prim? exp)
|
(define (prim? exp)
|
||||||
(or (member exp *primitives*)
|
(or (memq exp *primitives*)
|
||||||
(member exp *udf-prims*)))
|
(memq exp *udf-prims*)))
|
||||||
|
|
||||||
;; Does primitive mutate any of its arguments?
|
;; Does primitive mutate any of its arguments?
|
||||||
(define (prim:mutates? exp)
|
(define (prim:mutates? exp)
|
||||||
(member
|
(memq
|
||||||
exp
|
exp
|
||||||
'(
|
'(
|
||||||
Cyc-set-cvar!
|
Cyc-set-cvar!
|
||||||
|
@ -400,7 +400,7 @@
|
||||||
; (pair? ast)
|
; (pair? ast)
|
||||||
; (prim? (car ast))
|
; (prim? (car ast))
|
||||||
; ;; Does not make sense to precompute these
|
; ;; Does not make sense to precompute these
|
||||||
; (not (member (car ast)
|
; (not (memq (car ast)
|
||||||
; '(Cyc-global-vars
|
; '(Cyc-global-vars
|
||||||
; Cyc-get-cvar
|
; Cyc-get-cvar
|
||||||
; Cyc-set-cvar!
|
; Cyc-set-cvar!
|
||||||
|
@ -656,7 +656,7 @@
|
||||||
;; Does the primitive require passing thread data as its first argument?
|
;; Does the primitive require passing thread data as its first argument?
|
||||||
(define (prim/data-arg? p)
|
(define (prim/data-arg? p)
|
||||||
(or
|
(or
|
||||||
(member p '(
|
(memq p '(
|
||||||
Cyc-list
|
Cyc-list
|
||||||
Cyc-fast-plus
|
Cyc-fast-plus
|
||||||
Cyc-fast-sub
|
Cyc-fast-sub
|
||||||
|
@ -748,7 +748,7 @@
|
||||||
set-cdr!
|
set-cdr!
|
||||||
procedure?
|
procedure?
|
||||||
set-cell!))
|
set-cell!))
|
||||||
(member p *udf-prims*)))
|
(memq p *udf-prims*)))
|
||||||
|
|
||||||
;; Determine if primitive receives a pointer to a local C variable
|
;; Determine if primitive receives a pointer to a local C variable
|
||||||
(define (prim/c-var-pointer p)
|
(define (prim/c-var-pointer p)
|
||||||
|
@ -763,7 +763,7 @@
|
||||||
((eq? p 'Cyc-fast-sub) "complex_num_type")
|
((eq? p 'Cyc-fast-sub) "complex_num_type")
|
||||||
((eq? p 'Cyc-fast-mul) "complex_num_type")
|
((eq? p 'Cyc-fast-mul) "complex_num_type")
|
||||||
((eq? p 'Cyc-fast-div) "complex_num_type")
|
((eq? p 'Cyc-fast-div) "complex_num_type")
|
||||||
((member p *udf-prims*) "complex_num_type")
|
((memq p *udf-prims*) "complex_num_type")
|
||||||
(else #f)))
|
(else #f)))
|
||||||
|
|
||||||
;; TODO: this only makes sense for macros, all functions need to be removed from here.
|
;; TODO: this only makes sense for macros, all functions need to be removed from here.
|
||||||
|
@ -825,14 +825,14 @@
|
||||||
((eq? p 'list->vector) "object")
|
((eq? p 'list->vector) "object")
|
||||||
((eq? p 'Cyc-installation-dir) "object")
|
((eq? p 'Cyc-installation-dir) "object")
|
||||||
((eq? p 'Cyc-compilation-environment) "object")
|
((eq? p 'Cyc-compilation-environment) "object")
|
||||||
;((member p *udf-prims*) "object")
|
;((memq p *udf-prims*) "object")
|
||||||
(else #f)))
|
(else #f)))
|
||||||
|
|
||||||
;; Determine if primitive creates a C variable
|
;; Determine if primitive creates a C variable
|
||||||
(define (prim/cvar? exp)
|
(define (prim/cvar? exp)
|
||||||
(and (prim? exp)
|
(and (prim? exp)
|
||||||
(or
|
(or
|
||||||
(member exp '(
|
(memq exp '(
|
||||||
Cyc-stdout
|
Cyc-stdout
|
||||||
Cyc-stdin
|
Cyc-stdin
|
||||||
Cyc-stderr
|
Cyc-stderr
|
||||||
|
@ -879,13 +879,13 @@
|
||||||
;cons
|
;cons
|
||||||
;cell
|
;cell
|
||||||
))
|
))
|
||||||
;(member exp *udf-prims*)
|
;(memq exp *udf-prims*)
|
||||||
)))
|
)))
|
||||||
|
|
||||||
;; Pass continuation as the function's first parameter?
|
;; Pass continuation as the function's first parameter?
|
||||||
(define (prim:cont? exp)
|
(define (prim:cont? exp)
|
||||||
(and (prim? exp)
|
(and (prim? exp)
|
||||||
(member exp '(Cyc-read-line apply command-line-arguments number->string
|
(memq exp '(Cyc-read-line apply command-line-arguments number->string
|
||||||
Cyc-fast-apply
|
Cyc-fast-apply
|
||||||
+ - * /
|
+ - * /
|
||||||
= > < >= <=
|
= > < >= <=
|
||||||
|
@ -908,12 +908,12 @@
|
||||||
;; Primitive functions that pass a continuation or thread data but have no other arguments
|
;; Primitive functions that pass a continuation or thread data but have no other arguments
|
||||||
(define (prim:cont/no-args? exp)
|
(define (prim:cont/no-args? exp)
|
||||||
(and (prim? exp)
|
(and (prim? exp)
|
||||||
(member exp '(command-line-arguments Cyc-current-exception-handler))))
|
(memq exp '(command-line-arguments Cyc-current-exception-handler))))
|
||||||
|
|
||||||
;; Pass an integer arg count as the function's first parameter?
|
;; Pass an integer arg count as the function's first parameter?
|
||||||
(define (prim:arg-count? exp)
|
(define (prim:arg-count? exp)
|
||||||
(and (prim? exp)
|
(and (prim? exp)
|
||||||
(member exp '(error Cyc-write Cyc-display
|
(memq exp '(error Cyc-write Cyc-display
|
||||||
number->string string->number string-append
|
number->string string->number string-append
|
||||||
apply
|
apply
|
||||||
make-bytevector
|
make-bytevector
|
||||||
|
@ -930,7 +930,7 @@
|
||||||
(define (prim:allocates-object? exp use-alloca?)
|
(define (prim:allocates-object? exp use-alloca?)
|
||||||
(and (prim? exp)
|
(and (prim? exp)
|
||||||
use-alloca?
|
use-alloca?
|
||||||
(member exp
|
(memq exp
|
||||||
'(
|
'(
|
||||||
;cons
|
;cons
|
||||||
))))
|
))))
|
||||||
|
@ -938,7 +938,7 @@
|
||||||
;; Does the primitive only accept/return immutable objects?
|
;; Does the primitive only accept/return immutable objects?
|
||||||
;; This is useful during optimization
|
;; This is useful during optimization
|
||||||
(define (prim:immutable-args/result? sym)
|
(define (prim:immutable-args/result? sym)
|
||||||
(member sym
|
(memq sym
|
||||||
'(= > < >= <=
|
'(= > < >= <=
|
||||||
+ - * /
|
+ - * /
|
||||||
Cyc-fast-plus
|
Cyc-fast-plus
|
||||||
|
|
Loading…
Add table
Reference in a new issue