Commit 6d9a6b32 authored by David Gobbi's avatar David Gobbi Committed by Kitware Robot

Merge topic '15995-template-pydoc'

0dc76543 Fix cppcheck warning "index used before limits check"
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1293
parents 1521bd0a 0dc76543
......@@ -417,8 +417,8 @@ PyObject *PyVTKTemplate_NameFromKey(PyObject *self, PyObject *key)
name.push_back('L');
// guess the type based on available template instantiations
const char *trylist = (*tname == '-' ? "lxisa" : "lmxyijstah");
int bestfit = (*tname == '-' ? 5 : 10);
char typechar = 'l'; // C++ long is best fit for python int
int bestfit = 12;
PyObject *dict = PyModule_GetDict(self);
Py_ssize_t pos = 0;
PyObject *okey, *value;
......@@ -439,9 +439,9 @@ PyObject *PyVTKTemplate_NameFromKey(PyObject *self, PyObject *key)
{
// compare this template instance against the typecode
char c = cname[name.length()];
for (int k = 0; trylist[k]; k++)
for (int k = 0; k < bestfit; k++)
{
if (c == trylist[k] && k < bestfit)
if (c == trylist[k])
{
typechar = c;
bestfit = k;
......@@ -506,7 +506,7 @@ PyObject *PyVTKTemplate_NameFromKey(PyObject *self, PyObject *key)
// special compatibility code for 'long' (python 'int') to allow
// it to match either a 32-bit or a 64-bit integer
const char *trylist = (typechar == 'l' ? "lxi" : "myj");
int bestfit = 4;
int bestfit = 3;
PyObject *dict = PyModule_GetDict(self);
Py_ssize_t pos = 0;
PyObject *okey, *value;
......@@ -527,9 +527,9 @@ PyObject *PyVTKTemplate_NameFromKey(PyObject *self, PyObject *key)
{
// compare this template instance against the typecode
char c = cname[name.length()];
for (int k = 0; trylist[k]; k++)
for (int k = 0; k < bestfit; k++)
{
if (c == trylist[k] && k < bestfit)
if (c == trylist[k])
{
typechar = c;
bestfit = k;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment