From a05079fa6c7ef8a7d11f988164367f8a3588d0e9 Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Tue, 12 Sep 2023 12:52:25 -0400 Subject: [PATCH] gccrs: Memoize Backend::wchar_type gcc/rust/ChangeLog: * rust-gcc.cc (Backend::wchar_type): Store static wchar tree. Signed-off-by: Owen Avery --- 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; }