[gcc r14-8014] gccrs: Memoize Backend::wchar_type

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 18:13:35 GMT 2024


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

commit r14-8014-ga05079fa6c7ef8a7d11f988164367f8a3588d0e9
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Tue Sep 12 12:52:25 2023 -0400

    gccrs: Memoize Backend::wchar_type
    
    gcc/rust/ChangeLog:
    
            * rust-gcc.cc
            (Backend::wchar_type): Store static wchar tree.
    
    Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

Diff:
---
 gcc/rust/rust-gcc.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index be6e4ae5498..73c966a3320 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -345,8 +345,14 @@ get_identifier_node (const std::string &str)
 tree
 wchar_type ()
 {
-  tree wchar = make_unsigned_type (32);
-  TYPE_STRING_FLAG (wchar) = 1;
+  static tree wchar;
+
+  if (wchar == NULL_TREE)
+    {
+      wchar = make_unsigned_type (32);
+      TYPE_STRING_FLAG (wchar) = 1;
+    }
+
   return wchar;
 }


More information about the Gcc-cvs mailing list