mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 08:17:35 +02:00
Use only one comparison in closcall macros
This improves performance a bit since these macros are called after almost every C function.
This commit is contained in:
parent
84ecf2ac22
commit
199b685de3
3 changed files with 6 additions and 3 deletions
|
@ -90,6 +90,9 @@ enum object_tag {
|
||||||
, vector_tag // 19
|
, vector_tag // 19
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define type_is_pair_prim(clo) \
|
||||||
|
(type_of(clo) >= pair_tag)
|
||||||
|
|
||||||
// Define the size of object tags
|
// Define the size of object tags
|
||||||
typedef unsigned char tag_type;
|
typedef unsigned char tag_type;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index)
|
||||||
|
|
||||||
/* These macros are hardcoded here to support functions in this module. */
|
/* These macros are hardcoded here to support functions in this module. */
|
||||||
#define closcall1(td, clo, a1) \
|
#define closcall1(td, clo, a1) \
|
||||||
if (type_of(clo) == pair_tag || prim(clo)) { \
|
if (type_is_pair_prim(clo)) { \
|
||||||
Cyc_apply(td, 0, (closure)(a1), clo); \
|
Cyc_apply(td, 0, (closure)(a1), clo); \
|
||||||
} else { \
|
} else { \
|
||||||
((clo)->fn)(td, 1, clo, a1);\
|
((clo)->fn)(td, 1, clo, a1);\
|
||||||
|
@ -96,7 +96,7 @@ if (type_of(clo) == pair_tag || prim(clo)) { \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#define closcall2(td, clo, a1, a2) \
|
#define closcall2(td, clo, a1, a2) \
|
||||||
if (type_of(clo) == pair_tag || prim(clo)) { \
|
if (type_is_pair_prim(clo)) { \
|
||||||
Cyc_apply(td, 1, (closure)(a1), clo,a2); \
|
Cyc_apply(td, 1, (closure)(a1), clo,a2); \
|
||||||
} else { \
|
} else { \
|
||||||
((clo)->fn)(td, 2, clo, a1, a2);\
|
((clo)->fn)(td, 2, clo, a1, a2);\
|
||||||
|
|
|
@ -160,7 +160,7 @@
|
||||||
(wrap (lambda (s) (if (> num-args 0) s ""))))
|
(wrap (lambda (s) (if (> num-args 0) s ""))))
|
||||||
(string-append
|
(string-append
|
||||||
"#define closcall" n "(td, clo" args ") \\\n"
|
"#define closcall" n "(td, clo" args ") \\\n"
|
||||||
(wrap (string-append "if (type_of(clo) == pair_tag || prim(clo)) { \\\n"
|
(wrap (string-append "if (type_is_pair_prim(clo)) { \\\n"
|
||||||
" Cyc_apply(td, " n-1 ", (closure)(a1), clo" (if (> num-args 1) (substring args 3 (string-length args)) "") "); \\\n"
|
" Cyc_apply(td, " n-1 ", (closure)(a1), clo" (if (> num-args 1) (substring args 3 (string-length args)) "") "); \\\n"
|
||||||
"}"))
|
"}"))
|
||||||
(wrap " else { \\\n")
|
(wrap " else { \\\n")
|
||||||
|
|
Loading…
Add table
Reference in a new issue