From 3ef4142c7c2e4192aad6a32a6d45be50f37d805b Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 24 Jan 2024 01:41:33 +0200 Subject: [PATCH] cleanup, using the existing c.table.type_size --- vlib/v/checker/checker.v | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 25725d32191b1d..1cdf75f6cde35b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -3295,26 +3295,8 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type { } } else if to_type.is_int() && mut node.expr is ast.IntegerLiteral { tt := c.table.type_to_str(to_type) - bit_size := match to_type { - ast.u8_type, ast.i8_type, ast.char_type { - 8 - } - ast.u16_type, ast.i16_type { - 16 - } - ast.u32_type, ast.i32_type { - 32 - } - ast.u64_type, ast.i64_type { - 64 - } - ast.usize_type, ast.isize_type { - if c.pref.m64 { 64 } else { 32 } - } - else { - 0 - } - } + tsize, _ := c.table.type_size(to_type) + bit_size := tsize * 8 value_string := match node.expr.val[0] { `-`, `+` { node.expr.val[1..]