aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-05-02 16:53:17 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2023-05-11 09:38:21 +0200
commitb12481cf8ca462dd49ff101f50bda02418f777d8 (patch)
tree8ca43b6cdc8496561979adafde0c298661f9c2b3
parent8f6b7459551d535ac1d279964c0d30145cd75eb5 (diff)
downloadgcc-b12481cf8ca462dd49ff101f50bda02418f777d8.zip
gcc-b12481cf8ca462dd49ff101f50bda02418f777d8.tar.gz
gcc-b12481cf8ca462dd49ff101f50bda02418f777d8.tar.bz2
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 <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/rust/util/rust-token-converter.cc37
1 files changed, 12 insertions, 25 deletions
diff --git a/gcc/rust/util/rust-token-converter.cc b/gcc/rust/util/rust-token-converter.cc
index 344822f..b0d47de 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: