mes: Move pair? to core.

* src/lib.c (pair_p): New function.  Gains 8% performance on MesCC.
This commit is contained in:
Jan Nieuwenhuizen 2018-10-18 20:06:10 +02:00
parent 5ed45a4e24
commit 67046e1b00
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
9 changed files with 8 additions and 15 deletions

View file

@ -42,7 +42,6 @@
;; end boot-00.scm ;; end boot-00.scm
;; boot-01.scm ;; boot-01.scm
(define (pair? x) (eq? (core:type x) <cell:pair>))
(define (not x) (if x #f #t)) (define (not x) (if x #f #t))
(define (display x . rest) (define (display x . rest)

View file

@ -32,7 +32,6 @@
;; end boot-00.scm ;; end boot-00.scm
;; boot-01.scm ;; boot-01.scm
(define (pair? x) (eq? (core:type x) <cell:pair>))
(define (not x) (if x #f #t)) (define (not x) (if x #f #t))
(define (display x . rest) (define (display x . rest)

View file

@ -42,7 +42,6 @@
;; end boot-00.scm ;; end boot-00.scm
;; boot-01.scm ;; boot-01.scm
(define (pair? x) (eq? (core:type x) <cell:pair>))
(define (not x) (if x #f #t)) (define (not x) (if x #f #t))
(define (display x . rest) (define (display x . rest)

View file

@ -75,9 +75,6 @@
(define (number? x) (define (number? x)
(eq? (core:type x) <cell:number>)) (eq? (core:type x) <cell:number>))
(define (pair? x)
(eq? (core:type x) <cell:pair>))
(define (port? x) (define (port? x)
(eq? (core:type x) <cell:port>)) (eq? (core:type x) <cell:port>))

View file

@ -16,9 +16,6 @@
;;; You should have received a copy of the GNU General Public License ;;; You should have received a copy of the GNU General Public License
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(define (pair? x)
(eq? (core:type x) <cell:pair>))
(define (atom? x) (define (atom? x)
(if (pair? x) #f (if (pair? x) #f
(if (null? x) #f (if (null? x) #f

View file

@ -16,8 +16,6 @@
;;; You should have received a copy of the GNU General Public License ;;; You should have received a copy of the GNU General Public License
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(define (pair? x) (eq? (core:type x) <cell:pair>))
(define (not x) (if x #f #t)) (define (not x) (if x #f #t))
(define-macro (or . x) (define-macro (or . x)

View file

@ -16,7 +16,6 @@
;;; You should have received a copy of the GNU General Public License ;;; You should have received a copy of the GNU General Public License
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(define (pair? x) (eq? (core:type x) <cell:pair>))
(define (vector? x) (define (vector? x)
(eq? (core:type x) <cell:vector>)) (eq? (core:type x) <cell:vector>))
@ -85,7 +84,7 @@
;; ((lambda (a d) ;; ((lambda (a d)
;; (core:display " a=") (core:display a) (core:display "\n") ;; (core:display " a=") (core:display a) (core:display "\n")
;; (core:display " d=") (core:display d) ;; (core:display " d=") (core:display d)
;; (if (pair? d) ;; (if (pair? d)
;; (if (eq? (car d) 'quote) ;; (if (eq? (car d) 'quote)
;; (if (and (pair? a) (eq? (car a) 'quote)) ;; (if (and (pair? a) (eq? (car a) 'quote))
@ -133,7 +132,7 @@
(core:display "\n") (core:display "\n")
(core:display "CDR d=") (core:display d) (core:display "CDR d=") (core:display d)
(core:display "\n") (core:display "\n")
(if (pair? d) (if (pair? d)
(if (eq? (car d) 'quote) (if (eq? (car d) 'quote)
(if (and (pair? a) (eq? (car a) 'quote)) (if (and (pair? a) (eq? (car a) 'quote))

View file

@ -36,7 +36,6 @@
(define <cell:pair> 7) (define <cell:pair> 7)
(define <cell:string> 10) (define <cell:string> 10)
(define (pair? x) (eq? (core:type x) <cell:pair>))
(define (not x) (if x #f #t)) (define (not x) (if x #f #t))
(define (display x . rest) (define (display x . rest)

View file

@ -348,3 +348,9 @@ last_pair (SCM x)
x = CDR (x); x = CDR (x);
return x; return x;
} }
SCM
pair_p (SCM x)
{
return TYPE (x) == TPAIR ? cell_t : cell_f;
}