Skip to content

The improvement for xmpp_stanza_add_child. #169

@xbr-hw

Description

@xbr-hw

while (s->next)

When the size of stanza is big, the procedure time of get the tail node will be too long. Therefore, we can store then address of the tail node everytime we invoke xmpp_stanza_add_child. Next time we can get the tail node directly. Like this:

int xmpp_stanza_add_child(xmpp_stanza_t *stanza, xmpp_stanza_t *child)
{
xmpp_stanza_t *s;

/* get a reference to the child */
xmpp_stanza_clone(child);

child->parent = stanza;

if (!stanza->children)
    stanza->children = child;
else {
    **s = stanza->children_tail;**
    s->next = child;
    child->prev = s;
}

**stanza->children_tail = child;**
return XMPP_EOK;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions