mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-25 06:34:10 +00:00
Remove unneccessary value.
This commit is contained in:
parent
df2acc8569
commit
f2d07e5d69
1 changed files with 7 additions and 13 deletions
|
|
@ -25,14 +25,8 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct array_context {
|
|
||||||
unsigned int size;
|
|
||||||
unsigned int last;
|
|
||||||
array_context(unsigned int size) : size(size), last(0)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
struct unpack_user {
|
struct unpack_user {
|
||||||
stack<array_context> array_stack;
|
stack<unsigned int> array_stack;
|
||||||
map<string, PyObject*> str_cache;
|
map<string, PyObject*> str_cache;
|
||||||
|
|
||||||
~unpack_user() {
|
~unpack_user() {
|
||||||
|
|
@ -116,7 +110,7 @@ static inline int template_callback_false(unpack_user* u, msgpack_unpack_object*
|
||||||
static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_unpack_object* o)
|
static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_unpack_object* o)
|
||||||
{
|
{
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
u->array_stack.push(array_context(n));
|
u->array_stack.push(0);
|
||||||
*o = PyList_New(n);
|
*o = PyList_New(n);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -127,12 +121,12 @@ static inline int template_callback_array(unpack_user* u, unsigned int n, msgpac
|
||||||
|
|
||||||
static inline int template_callback_array_item(unpack_user* u, msgpack_unpack_object* c, msgpack_unpack_object o)
|
static inline int template_callback_array_item(unpack_user* u, msgpack_unpack_object* c, msgpack_unpack_object o)
|
||||||
{
|
{
|
||||||
unsigned int n = u->array_stack.top().size;
|
unsigned int &last = u->array_stack.top();
|
||||||
unsigned int &last = u->array_stack.top().last;
|
PyList_SET_ITEM(*c, last, o);
|
||||||
|
|
||||||
PyList_SetItem(*c, last, o);
|
|
||||||
last++;
|
last++;
|
||||||
if (last >= n) {
|
|
||||||
|
Py_ssize_t len = PyList_GET_SIZE(*c);
|
||||||
|
if (last >= len) {
|
||||||
u->array_stack.pop();
|
u->array_stack.pop();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue