mirror of
https://github.com/python/cpython.git
synced 2025-09-14 12:46:49 +00:00
Two improvements suggested by Greg Stein:
PyString_FromFormatV(): In the final resize at the end, we can use PyString_AS_STRING() since we know the object is a string and can avoid the typechecking. PyString_FromFormat(): GS sez: "For safety/propriety, you should call va_end() on the vargs variable."
This commit is contained in:
parent
5a6fdcd371
commit
7c47beb860
1 changed files with 5 additions and 2 deletions
|
@ -292,13 +292,14 @@ PyString_FromFormatV(const char *format, va_list vargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
_PyString_Resize(&string, s - PyString_AsString(string));
|
_PyString_Resize(&string, s - PyString_AS_STRING(string));
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyString_FromFormat(const char *format, ...)
|
PyString_FromFormat(const char *format, ...)
|
||||||
{
|
{
|
||||||
|
PyObject* ret;
|
||||||
va_list vargs;
|
va_list vargs;
|
||||||
|
|
||||||
#ifdef HAVE_STDARG_PROTOTYPES
|
#ifdef HAVE_STDARG_PROTOTYPES
|
||||||
|
@ -306,7 +307,9 @@ PyString_FromFormat(const char *format, ...)
|
||||||
#else
|
#else
|
||||||
va_start(vargs);
|
va_start(vargs);
|
||||||
#endif
|
#endif
|
||||||
return PyString_FromFormatV(format, vargs);
|
ret = PyString_FromFormatV(format, vargs);
|
||||||
|
va_end(vargs);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue