Slight performance tweak for templates

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11834 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-01-29 18:49:16 +00:00
commit 160ce6d4a8
4 changed files with 41 additions and 45 deletions

View file

@ -474,25 +474,12 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
Delete(cls);
}
/* A template-based class lookup, check name first */
if (!rn && SwigType_istemplate(name)) {
String *t_name = SwigType_templateprefix(name);
if (!Equal(t_name, name)) {
if (!rn) {
String *t_name = SwigType_istemplate_templateprefix(name);
if (t_name)
rn = Swig_name_object_get(namehash, prefix, t_name, decl);
}
Delete(t_name);
}
/* A template-based class lookup */
/*
if (!rn && SwigType_istemplate(prefix)) {
String *t_prefix = SwigType_templateprefix(prefix);
if (Strcmp(t_prefix, prefix) != 0) {
String *t_name = SwigType_templateprefix(name);
rn = Swig_name_object_get(namehash, t_prefix, t_name, decl);
Delete(t_name);
}
Delete(t_prefix);
}
*/
}
/* A wildcard-based class lookup */
if (!rn) {
@ -663,10 +650,9 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
if (name) {
String *tname = NewStringEmpty();
/* add features for 'root' template */
if (SwigType_istemplate(name)) {
String *dname = SwigType_templateprefix(name);
String *dname = SwigType_istemplate_templateprefix(name);
if (dname) {
features_get(features, dname, decl, ncdecl, node);
Delete(dname);
}
/* Catch-all */
features_get(features, name, decl, ncdecl, node);
@ -684,16 +670,16 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
/* A specific class lookup */
if (Len(prefix)) {
/* A template-based class lookup */
if (SwigType_istemplate(prefix)) {
String *tprefix = SwigType_templateprefix(prefix);
String *tprefix = SwigType_istemplate_templateprefix(prefix);
if (tprefix) {
Clear(tname);
Printf(tname, "%s::%s", tprefix, name);
features_get(features, tname, decl, ncdecl, node);
Delete(tprefix);
}
Clear(tname);
Printf(tname, "%s::%s", prefix, name);
features_get(features, tname, decl, ncdecl, node);
Delete(tprefix);
}
} else {
/* Lookup in the global namespace only */
@ -702,6 +688,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
features_get(features, tname, decl, ncdecl, node);
}
Delete(tname);
Delete(dname);
}
if (name && SwigType_istemplate(name)) {
/* add features for complete template type */

View file

@ -1161,9 +1161,9 @@ int SwigType_isclass(SwigType *t) {
isclass = 1;
}
/* Hmmm. Not a class. If a template, it might be uninstantiated */
if (!isclass && SwigType_istemplate(qtys)) {
String *tp = SwigType_templateprefix(qtys);
if (Strcmp(tp, t) != 0) {
if (!isclass) {
String *tp = SwigType_istemplate_templateprefix(qtys);
if (tp && Strcmp(tp, t) != 0) {
isclass = SwigType_isclass(tp);
}
Delete(tp);