mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-12 12:50:28 +00:00
skip unnecessary strcmp in create_builtin
This commit is contained in:
parent
f242ef4a09
commit
e44528ee86
1 changed files with 25 additions and 27 deletions
52
third_party/python/Python/import.c
vendored
52
third_party/python/Python/import.c
vendored
|
@ -95,8 +95,8 @@ module _imp
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
union {
|
union {
|
||||||
struct _inittab *tab;
|
const struct _inittab *tab;
|
||||||
struct _frozen *frz;
|
const struct _frozen *frz;
|
||||||
};
|
};
|
||||||
} initentry;
|
} initentry;
|
||||||
|
|
||||||
|
@ -1183,36 +1183,34 @@ _imp_create_builtin(PyObject *module, PyObject *spec)
|
||||||
if (res != NULL) {
|
if (res != NULL) {
|
||||||
p = res->tab;
|
p = res->tab;
|
||||||
PyModuleDef *def;
|
PyModuleDef *def;
|
||||||
if (_PyUnicode_EqualToASCIIString(name, p->name)) {
|
if (p->initfunc == NULL) {
|
||||||
if (p->initfunc == NULL) {
|
/* Cannot re-init internal module ("sys" or "builtins") */
|
||||||
/* Cannot re-init internal module ("sys" or "builtins") */
|
mod = PyImport_AddModule(namestr);
|
||||||
mod = PyImport_AddModule(namestr);
|
Py_DECREF(name);
|
||||||
Py_DECREF(name);
|
return mod;
|
||||||
return mod;
|
}
|
||||||
}
|
mod = (*p->initfunc)();
|
||||||
mod = (*p->initfunc)();
|
if (mod == NULL) {
|
||||||
if (mod == NULL) {
|
Py_DECREF(name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (PyObject_TypeCheck(mod, &PyModuleDef_Type)) {
|
||||||
|
Py_DECREF(name);
|
||||||
|
return PyModule_FromDefAndSpec((PyModuleDef*)mod, spec);
|
||||||
|
} else {
|
||||||
|
/* Remember pointer to module init function. */
|
||||||
|
def = PyModule_GetDef(mod);
|
||||||
|
if (def == NULL) {
|
||||||
Py_DECREF(name);
|
Py_DECREF(name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (PyObject_TypeCheck(mod, &PyModuleDef_Type)) {
|
def->m_base.m_init = p->initfunc;
|
||||||
|
if (_PyImport_FixupExtensionObject(mod, name, name) < 0) {
|
||||||
Py_DECREF(name);
|
Py_DECREF(name);
|
||||||
return PyModule_FromDefAndSpec((PyModuleDef*)mod, spec);
|
return NULL;
|
||||||
} else {
|
|
||||||
/* Remember pointer to module init function. */
|
|
||||||
def = PyModule_GetDef(mod);
|
|
||||||
if (def == NULL) {
|
|
||||||
Py_DECREF(name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
def->m_base.m_init = p->initfunc;
|
|
||||||
if (_PyImport_FixupExtensionObject(mod, name, name) < 0) {
|
|
||||||
Py_DECREF(name);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Py_DECREF(name);
|
|
||||||
return mod;
|
|
||||||
}
|
}
|
||||||
|
Py_DECREF(name);
|
||||||
|
return mod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_DECREF(name);
|
Py_DECREF(name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue