Avoid calling getFunctionWrapperName() twice for each function

Pass the wrapper name to emit_wrapper_func_decl() to save on an extra
call to this function.

No real changes, this is just an optimization.
This commit is contained in:
Vadim Zeitlin 2021-11-06 20:43:33 +01:00
commit 2f4a09fb21

View file

@ -813,7 +813,7 @@ public:
Wrapper_print(wrapper, f_wrappers); Wrapper_print(wrapper, f_wrappers);
emit_wrapper_func_decl(n, name); emit_wrapper_func_decl(n, name, wname);
// cleanup // cleanup
Delete(proto); Delete(proto);
@ -972,14 +972,12 @@ public:
* Also emits a define allowing to use the function without the "_wrap_" prefix. * Also emits a define allowing to use the function without the "_wrap_" prefix.
* The node here is a function declaration. * The node here is a function declaration.
* ---------------------------------------------------------------------- */ * ---------------------------------------------------------------------- */
void emit_wrapper_func_decl(Node *n, String *name) void emit_wrapper_func_decl(Node *n, String *name, String *wname)
{ {
current_output = output_wrapper_decl; current_output = output_wrapper_decl;
maybe_owned_dohptr wname = getFunctionWrapperName(n, name);
// add function declaration to the proxy header file // add function declaration to the proxy header file
Printv(f_wrappers_decl, "SWIGIMPORT ", get_wrapper_func_return_type(n).get(), " ", wname.get(), get_wrapper_func_proto(n).get(), ";\n\n", NIL); Printv(f_wrappers_decl, "SWIGIMPORT ", get_wrapper_func_return_type(n).get(), " ", wname, get_wrapper_func_proto(n).get(), ";\n\n", NIL);
if (Cmp(name, wname) != 0) { if (Cmp(name, wname) != 0) {
if (!f_wrappers_aliases) { if (!f_wrappers_aliases) {
@ -988,7 +986,7 @@ public:
Printv(f_wrappers_aliases, "#ifdef SWIG_DEFINE_WRAPPER_ALIASES\n", NIL); Printv(f_wrappers_aliases, "#ifdef SWIG_DEFINE_WRAPPER_ALIASES\n", NIL);
} }
Printf(f_wrappers_aliases, "#define %s %s\n", name, wname.get()); Printf(f_wrappers_aliases, "#define %s %s\n", name, wname);
} }
} }
@ -1116,6 +1114,8 @@ public:
// cleanup // cleanup
DelWrapper(wrapper); DelWrapper(wrapper);
emit_wrapper_func_decl(n, name, wname);
} }
void functionWrapperCPPSpecific(Node *n) void functionWrapperCPPSpecific(Node *n)
@ -1167,7 +1167,6 @@ public:
// C++ function wrapper // C++ function wrapper
functionWrapperCPPSpecificWrapper(n, name); functionWrapperCPPSpecificWrapper(n, name);
emit_wrapper_func_decl(n, name);
Delete(name); Delete(name);
} }