Skip to content

Commit fe28060

Browse files
authored
Simplify jsmath.c. NFC (#23144)
`casttype` is always identical to `type` so is not needed. Also the actual cast operation is never needed since the argument type is always declared correctly.
1 parent 3502b82 commit fe28060

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

system/lib/jsmath.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
#include <math.h>
77
#include <stdlib.h>
88

9-
#define CALL_JS_1(cname, jsname, type, casttype) \
9+
#define CALL_JS_1(cname, jsname, type) \
1010
EM_JS(type, JS_##cname, (type x), { return jsname(x) }); \
11-
type cname(type x) { return JS_##cname((casttype)x); }
11+
type cname(type x) { return JS_##cname(x); }
1212

1313
#define CALL_JS_1_TRIPLE(cname, jsname) \
14-
CALL_JS_1(cname, jsname, double, double) \
15-
CALL_JS_1(cname##f, jsname, float, float)
14+
CALL_JS_1(cname, jsname, double) \
15+
CALL_JS_1(cname##f, jsname, float)
1616

1717
CALL_JS_1_TRIPLE(cos, Math.cos)
1818
CALL_JS_1_TRIPLE(sin, Math.sin)
@@ -27,24 +27,24 @@ CALL_JS_1_TRIPLE(fabs, Math.abs)
2727
CALL_JS_1_TRIPLE(ceil, Math.ceil)
2828
CALL_JS_1_TRIPLE(floor, Math.floor)
2929

30-
#define CALL_JS_2(cname, jsname, type, casttype) \
30+
#define CALL_JS_2(cname, jsname, type) \
3131
EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \
32-
type cname(type x, type y) { return JS_##cname((casttype)x, (casttype)y); }
32+
type cname(type x, type y) { return JS_##cname(x, y); }
3333

3434
#define CALL_JS_2_TRIPLE(cname, jsname) \
35-
CALL_JS_2(cname, jsname, double, double) \
36-
CALL_JS_2(cname##f, jsname, float, float)
35+
CALL_JS_2(cname, jsname, double) \
36+
CALL_JS_2(cname##f, jsname, float)
3737

3838
CALL_JS_2_TRIPLE(atan2, Math.atan2)
3939
CALL_JS_2_TRIPLE(pow, Math.pow)
4040

41-
#define CALL_JS_1_IMPL(cname, type, casttype, impl) \
41+
#define CALL_JS_1_IMPL(cname, type, impl) \
4242
EM_JS(type, JS_##cname, (type x), impl); \
43-
type cname(type x) { return JS_##cname((casttype)x); }
43+
type cname(type x) { return JS_##cname(x); }
4444

4545
#define CALL_JS_1_IMPL_TRIPLE(cname, impl) \
46-
CALL_JS_1_IMPL(cname, double, double, impl) \
47-
CALL_JS_1_IMPL(cname##f, float, float, impl)
46+
CALL_JS_1_IMPL(cname, double, impl) \
47+
CALL_JS_1_IMPL(cname##f, float, impl)
4848

4949
CALL_JS_1_IMPL_TRIPLE(round, {
5050
return x >= 0 ? Math.floor(x + 0.5) : Math.ceil(x - 0.5);

0 commit comments

Comments
 (0)