mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
option to disable bounds checking; examples/path_tracing.v: optimizations
This commit is contained in:
@ -140,6 +140,25 @@ $c_common_macros
|
||||
#define DEFAULT_LE(a, b) (a <= b)
|
||||
#define DEFAULT_GT(a, b) (a > b)
|
||||
#define DEFAULT_GE(a, b) (a >= b)
|
||||
|
||||
// NB: macro_fXX_eq and macro_fXX_ne are NOT used
|
||||
// in the generated C code. They are here just for
|
||||
// completeness/testing.
|
||||
|
||||
#define macro_f64_eq(a, b) (a == b)
|
||||
#define macro_f64_ne(a, b) (a != b)
|
||||
#define macro_f64_lt(a, b) (a < b)
|
||||
#define macro_f64_le(a, b) (a <= b)
|
||||
#define macro_f64_gt(a, b) (a > b)
|
||||
#define macro_f64_ge(a, b) (a >= b)
|
||||
|
||||
#define macro_f32_eq(a, b) (a == b)
|
||||
#define macro_f32_ne(a, b) (a != b)
|
||||
#define macro_f32_lt(a, b) (a < b)
|
||||
#define macro_f32_le(a, b) (a <= b)
|
||||
#define macro_f32_gt(a, b) (a > b)
|
||||
#define macro_f32_ge(a, b) (a >= b)
|
||||
|
||||
//================================== GLOBALS =================================*/
|
||||
byte g_str_buf[1024];
|
||||
int load_so(byteptr);
|
||||
|
@ -217,6 +217,10 @@ fn (p mut Parser) bterm() string {
|
||||
if is_float && p.cur_fn.name != 'f32_abs' && p.cur_fn.name != 'f64_abs' {
|
||||
p.gen(')')
|
||||
match tok {
|
||||
// NB: For more precision/stability, the == and != float
|
||||
// comparisons are done with V functions that use the epsilon
|
||||
// constants for the given type.
|
||||
// Everything else uses native comparisons (C macros) for speed.
|
||||
.eq {
|
||||
p.cgen.set_placeholder(ph, '${expr_type}_eq(')
|
||||
}
|
||||
@ -224,16 +228,16 @@ fn (p mut Parser) bterm() string {
|
||||
p.cgen.set_placeholder(ph, '${expr_type}_ne(')
|
||||
}
|
||||
.le {
|
||||
p.cgen.set_placeholder(ph, '${expr_type}_le(')
|
||||
p.cgen.set_placeholder(ph, 'macro_${expr_type}_le(')
|
||||
}
|
||||
.ge {
|
||||
p.cgen.set_placeholder(ph, '${expr_type}_ge(')
|
||||
p.cgen.set_placeholder(ph, 'macro_${expr_type}_ge(')
|
||||
}
|
||||
.gt {
|
||||
p.cgen.set_placeholder(ph, '${expr_type}_gt(')
|
||||
p.cgen.set_placeholder(ph, 'macro_${expr_type}_gt(')
|
||||
}
|
||||
.lt {
|
||||
p.cgen.set_placeholder(ph, '${expr_type}_lt(')
|
||||
p.cgen.set_placeholder(ph, 'macro_${expr_type}_lt(')
|
||||
}
|
||||
else {
|
||||
}}
|
||||
|
Reference in New Issue
Block a user