From 8adfcf712160dbdda2cf506c54da291e00afb010 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Tue, 2 May 2023 16:53:17 +0200 Subject: [PATCH] gccrs: converter: Remove redundant variable Since the introduction of this variable the code has changed and no value order preservation is required anymore, the comparison can be done inline. gcc/rust/ChangeLog: * util/rust-token-converter.cc (dispatch_float_literals): Remove suffixed temporary variable. (dispatch_integer_literals): Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/util/rust-token-converter.cc | 37 +++++++++------------------ 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/gcc/rust/util/rust-token-converter.cc b/gcc/rust/util/rust-token-converter.cc index 344822f5ea0a..b0d47de512f7 100644 --- a/gcc/rust/util/rust-token-converter.cc +++ b/gcc/rust/util/rust-token-converter.cc @@ -39,16 +39,14 @@ dispatch_float_literals (ProcMacro::TokenStream &ts, TokenPtr &token) { case CORETYPE_F32: { auto value = std::stof (str, &sz); - bool suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_f32 (value, suffixed))); + ProcMacro::Literal::make_f32 (value, sz == str.length ()))); } break; case CORETYPE_F64: { auto value = std::stod (str, &sz); - bool suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_f64 (value, suffixed))); + ProcMacro::Literal::make_f64 (value, sz == str.length ()))); } break; default: @@ -63,69 +61,58 @@ dispatch_integer_literals (ProcMacro::TokenStream &ts, TokenPtr &token) auto str = token->as_string (); unsigned long long uvalue; long long svalue; - bool suffixed = false; switch (token->get_type_hint ()) { case CORETYPE_U8: uvalue = std::stoull (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_u8 (uvalue, suffixed))); + ProcMacro::Literal::make_u8 (uvalue, sz == str.length ()))); break; case CORETYPE_U16: uvalue = std::stoull (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_u16 (uvalue, suffixed))); + ProcMacro::Literal::make_u16 (uvalue, sz == str.length ()))); break; case CORETYPE_U32: uvalue = std::stoull (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_u32 (uvalue, suffixed))); + ProcMacro::Literal::make_u32 (uvalue, sz == str.length ()))); break; case CORETYPE_U64: uvalue = std::stoull (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_u32 (uvalue, suffixed))); + ProcMacro::Literal::make_u32 (uvalue, sz == str.length ()))); break; case CORETYPE_I8: svalue = std::stoll (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_i8 (svalue, suffixed))); + ProcMacro::Literal::make_i8 (svalue, sz == str.length ()))); break; case CORETYPE_I16: svalue = std::stoll (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_i16 (svalue, suffixed))); + ProcMacro::Literal::make_i16 (svalue, sz == str.length ()))); break; case CORETYPE_I32: svalue = std::stoll (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_i32 (svalue, suffixed))); + ProcMacro::Literal::make_i32 (svalue, sz == str.length ()))); break; case CORETYPE_I64: svalue = std::stoll (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_i32 (svalue, suffixed))); + ProcMacro::Literal::make_i32 (svalue, sz == str.length ()))); break; case CORETYPE_INT: svalue = std::stoll (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_isize (svalue, suffixed))); + ProcMacro::Literal::make_isize (svalue, sz == str.length ()))); break; case CORETYPE_UINT: uvalue = std::stoull (str, &sz); - suffixed = sz == str.length (); ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_usize (uvalue, suffixed))); + ProcMacro::Literal::make_usize (uvalue, sz == str.length ()))); break; case CORETYPE_UNKNOWN: default: -- 2.47.2