diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-12-07 15:59:37 -0500 |
| commit | a201939a8150bc4c2f221925797ea2751c74b77c (patch) | |
| tree | 26fee4ec601319fd8771435087931023e393fe92 /compile.c | |
| parent | 683b0f5141ad21914d77cd4b4b81e7e2161f90f3 (diff) | |
Use likely()/unlikely() macros and a few bugfixes for integers
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -73,8 +73,8 @@ static bool promote(env_t *env, ast_t *ast, CORD *code, type_t *actual, type_t * // Automatic optional checking for nums: if (needed->tag == NumType && actual->tag == OptionalType && Match(actual, OptionalType)->type->tag == NumType) { *code = CORD_all("({ ", compile_declaration(actual, "opt"), " = ", *code, "; ", - "if (__builtin_expect(", check_none(actual, "opt"), ", 0))\n", - CORD_asprintf("fail_source(%r, %ld, %ld, \"This value was expected to be non-NONE, but it's NONE!\");\n", + "if unlikely (", check_none(actual, "opt"), ")\n", + CORD_asprintf("fail_source(%r, %ld, %ld, \"This was expected to be a value, but it's NONE\");\n", CORD_quoted(ast->file->filename), (long)(ast->start - ast->file->text), (long)(ast->end - ast->file->text)), @@ -2121,8 +2121,8 @@ CORD compile(env_t *env, ast_t *ast) type_t *t = get_type(env, value); CORD value_code = compile(env, value); return CORD_all("({ ", compile_declaration(t, "opt"), " = ", value_code, "; ", - "if (__builtin_expect(", check_none(t, "opt"), ", 0))\n", - CORD_asprintf("fail_source(%r, %ld, %ld, \"This value was expected to be non-NONE, but it's NONE!\");\n", + "if unlikely (", check_none(t, "opt"), ")\n", + CORD_asprintf("fail_source(%r, %ld, %ld, \"This was expected to be a value, but it's NONE\");\n", CORD_quoted(ast->file->filename), (long)(value->start - value->file->text), (long)(value->end - value->file->text)), |
