]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: converter: Remove redundant variable
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 2 May 2023 14:53:17 +0000 (16:53 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:37:17 +0000 (18:37 +0100)
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 <pierre-emmanuel.patry@embecosm.com>
gcc/rust/util/rust-token-converter.cc

index 344822f5ea0af38009732954bc0373882e364160..b0d47de512f7b971c967924266e17c71cab15a38 100644 (file)
@@ -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: