]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Memoize Backend::wchar_type
authorOwen Avery <powerboat9.gamer@gmail.com>
Tue, 12 Sep 2023 16:52:25 +0000 (12:52 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:36 +0000 (19:04 +0100)
gcc/rust/ChangeLog:

* rust-gcc.cc
(Backend::wchar_type): Store static wchar tree.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/rust-gcc.cc

index be6e4ae5498fe368ea2a09db019b0c54a6ce42d5..73c966a3320cb431520fd769861663244f5d22b7 100644 (file)
@@ -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;
 }