From 8fa77121fbf77c739287f987962c885b5a63cd98 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 9 Sep 2024 12:16:14 +0900 Subject: [PATCH] Reduce unnecessary checks If `have_header` returns `false`, `have_func` using that header also return `false` always, because that header cannot be included. --- ext/bigdecimal/extconf.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb index 23904ed6..cf4290f5 100644 --- a/ext/bigdecimal/extconf.rb +++ b/ext/bigdecimal/extconf.rb @@ -24,15 +24,17 @@ def have_builtin_func(name, check_expr, opt = "", &b) have_header("stdbool.h") have_header("stdlib.h") -have_header("x86intrin.h") -have_func("_lzcnt_u32", "x86intrin.h") -have_func("_lzcnt_u64", "x86intrin.h") - -have_header("intrin.h") -have_func("__lzcnt", "intrin.h") -have_func("__lzcnt64", "intrin.h") -have_func("_BitScanReverse", "intrin.h") -have_func("_BitScanReverse64", "intrin.h") +if have_header("x86intrin.h") + have_func("_lzcnt_u32", "x86intrin.h") + have_func("_lzcnt_u64", "x86intrin.h") +end + +if have_header("intrin.h") + have_func("__lzcnt", "intrin.h") + have_func("__lzcnt64", "intrin.h") + have_func("_BitScanReverse", "intrin.h") + have_func("_BitScanReverse64", "intrin.h") +end have_func("labs", "stdlib.h") have_func("llabs", "stdlib.h")