提交 44ad9cd8 编写于 作者: T Tom Zanussi 提交者: Frederic Weisbecker

perf/scripts: Remove unnecessary PyTuple resizes

If we know the size of a tuple in advance, there's no need to resize
it - start out with the known size in the first place.
Signed-off-by: NTom Zanussi <tzanussi@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Keiichi KII <k-keiichi@bx.jp.nec.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <1266822779.6426.4.camel@tropicana>
Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
上级 4d161f03
......@@ -68,7 +68,7 @@ static void define_value(enum print_arg_type field_type,
if (field_type == PRINT_SYMBOL)
handler_name = "define_symbolic_value";
t = PyTuple_New(MAX_FIELDS);
t = PyTuple_New(4);
if (!t)
Py_FatalError("couldn't create Python tuple");
......@@ -79,9 +79,6 @@ static void define_value(enum print_arg_type field_type,
PyTuple_SetItem(t, n++, PyInt_FromLong(value));
PyTuple_SetItem(t, n++, PyString_FromString(field_str));
if (_PyTuple_Resize(&t, n) == -1)
Py_FatalError("error resizing Python tuple");
handler = PyDict_GetItemString(main_dict, handler_name);
if (handler && PyCallable_Check(handler)) {
retval = PyObject_CallObject(handler, t);
......@@ -116,7 +113,10 @@ static void define_field(enum print_arg_type field_type,
if (field_type == PRINT_SYMBOL)
handler_name = "define_symbolic_field";
t = PyTuple_New(MAX_FIELDS);
if (field_type == PRINT_FLAGS)
t = PyTuple_New(3);
else
t = PyTuple_New(2);
if (!t)
Py_FatalError("couldn't create Python tuple");
......@@ -125,9 +125,6 @@ static void define_field(enum print_arg_type field_type,
if (field_type == PRINT_FLAGS)
PyTuple_SetItem(t, n++, PyString_FromString(delim));
if (_PyTuple_Resize(&t, n) == -1)
Py_FatalError("error resizing Python tuple");
handler = PyDict_GetItemString(main_dict, handler_name);
if (handler && PyCallable_Check(handler)) {
retval = PyObject_CallObject(handler, t);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册