From 9615021a910d283833033ed8af990c356183f3e3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Aug 2019 17:01:13 +0200 Subject: [PATCH] Micro optimize handling of prefix in get_mangled_type() Don't bother with a bunch of Replaceall() calls if the prefix is empty to begin with, which is commonly the case. No real changes. --- Source/Modules/c.cxx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx index 7cbf25b67..81415bcd8 100644 --- a/Source/Modules/c.cxx +++ b/Source/Modules/c.cxx @@ -560,7 +560,6 @@ public: String *get_mangled_type(SwigType *type_arg) { String *result = NewString(""); - SwigType *prefix = 0; SwigType *type = 0; SwigType *tdtype = SwigType_typedef_resolve_all(type_arg); if (tdtype) @@ -584,16 +583,18 @@ public: type = Copy(type_arg); } - prefix = SwigType_prefix(type); - Replaceall(prefix, ".", ""); - Replaceall(prefix, "const", "c"); - Replaceall(prefix, "volatile", "v"); - Replaceall(prefix, "a(", "a"); - Replaceall(prefix, "m(", "m"); - Replaceall(prefix, "q(", ""); - Replaceall(prefix, ")", ""); - Replaceall(prefix, " ", ""); - Printf(result, "%s", prefix); + SwigType *prefix = SwigType_prefix(type); + if (Len(prefix)) { + Replaceall(prefix, ".", ""); + Replaceall(prefix, "const", "c"); + Replaceall(prefix, "volatile", "v"); + Replaceall(prefix, "a(", "a"); + Replaceall(prefix, "m(", "m"); + Replaceall(prefix, "q(", ""); + Replaceall(prefix, ")", ""); + Replaceall(prefix, " ", ""); + Printf(result, "%s", prefix); + } type = SwigType_base(type); if (SwigType_isbuiltin(type))