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.
This commit is contained in:
Vadim Zeitlin 2019-08-04 17:01:13 +02:00
commit 9615021a91

View file

@ -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))