https://gcc.gnu.org/g:c9f0f9347453842218e30616fa7ecc5366e6b7e5

commit r17-1888-gc9f0f9347453842218e30616fa7ecc5366e6b7e5
Author: Enes Cevik <[email protected]>
Date:   Wed Jun 3 12:20:32 2026 +0300

    gccrs: Remove reduntant as_string calls.
    
    gcc/rust/ChangeLog:
    
            * backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl):
            Remove reduntant as_string calls.
    
    Signed-off-by: Enes Cevik <[email protected]>

Diff:
---
 gcc/rust/backend/rust-compile-base.cc | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-base.cc 
b/gcc/rust/backend/rust-compile-base.cc
index 340e2617882b..f566cc07b738 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -78,24 +78,19 @@ HIRCompileBase::setup_fndecl (tree fndecl, bool 
is_main_entry_point,
   // is it inline?
   for (const auto &attr : attrs)
     {
-      bool is_inline
-       = attr.get_path ().as_string () == Values::Attributes::INLINE;
-      bool is_must_use
-       = attr.get_path ().as_string () == Values::Attributes::MUST_USE;
-      bool is_cold = attr.get_path ().as_string () == Values::Attributes::COLD;
-      bool is_link_section
-       = attr.get_path ().as_string () == Values::Attributes::LINK_SECTION;
-      bool no_mangle
-       = attr.get_path ().as_string () == Values::Attributes::NO_MANGLE;
-      bool is_deprecated
-       = attr.get_path ().as_string () == Values::Attributes::DEPRECATED;
-      bool is_proc_macro
-       = attr.get_path ().as_string () == Values::Attributes::PROC_MACRO;
+      std::string attr_str = attr.get_path ().as_string ();
+
+      bool is_inline = attr_str == Values::Attributes::INLINE;
+      bool is_must_use = attr_str == Values::Attributes::MUST_USE;
+      bool is_cold = attr_str == Values::Attributes::COLD;
+      bool is_link_section = attr_str == Values::Attributes::LINK_SECTION;
+      bool no_mangle = attr_str == Values::Attributes::NO_MANGLE;
+      bool is_deprecated = attr_str == Values::Attributes::DEPRECATED;
+      bool is_proc_macro = attr_str == Values::Attributes::PROC_MACRO;
       bool is_proc_macro_attribute
-       = attr.get_path ().as_string ()
-         == Values::Attributes::PROC_MACRO_ATTRIBUTE;
-      bool is_proc_macro_derive = attr.get_path ().as_string ()
-                                 == Values::Attributes::PROC_MACRO_DERIVE;
+       = attr_str == Values::Attributes::PROC_MACRO_ATTRIBUTE;
+      bool is_proc_macro_derive
+       = attr_str == Values::Attributes::PROC_MACRO_DERIVE;
 
       if (is_inline)
        {

Reply via email to