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 4e1f494d19
commit d9199b3536
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;
}