summaryrefslogtreecommitdiffstats
path: root/axiom
diff options
context:
space:
mode:
authorGravatar shankar2010-03-24 07:49:24 +0000
committerGravatar shankar2010-03-24 07:49:24 +0000
commit22c8c7829076c148471490bd8b56de2b36d191c6 (patch)
tree5b457acd4316ec743b9f20a11b91187ee2398272 /axiom
parentfb58131071e0fd446fb8f0910cb642fd0606e9d1 (diff)
downloadaxis2c-22c8c7829076c148471490bd8b56de2b36d191c6.tar.gz
axis2c-22c8c7829076c148471490bd8b56de2b36d191c6.tar.bz2
refactor to improve performance
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@926964 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'axiom')
-rw-r--r--axiom/src/om/om_comment.c19
-rw-r--r--axiom/src/om/om_element.c1
-rw-r--r--axiom/src/om/om_namespace.c1
-rw-r--r--axiom/src/om/om_stax_builder.c58
-rw-r--r--axiom/src/om/om_text.c30
5 files changed, 47 insertions, 62 deletions
diff --git a/axiom/src/om/om_comment.c b/axiom/src/om/om_comment.c
index ad17f74..2aa9f7f 100644
--- a/axiom/src/om/om_comment.c
+++ b/axiom/src/om/om_comment.c
@@ -34,14 +34,13 @@ axiom_comment_create(
axiom_node_t ** node)
{
axiom_comment_t *comment = NULL;
- AXIS2_ENV_CHECK(env, NULL);
AXIS2_PARAM_CHECK(env->error, value, NULL);
AXIS2_PARAM_CHECK(env->error, node, NULL);
- *node = NULL;
*node = axiom_node_create(env);
if(!*node)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create node needed by om comment");
return NULL;
}
@@ -50,22 +49,26 @@ axiom_comment_create(
{
AXIS2_FREE(env->allocator, (*node));
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create om comment");
return NULL;
}
- comment->value = NULL;
-
if(value)
{
comment->value = (axis2_char_t *)axutil_strdup(env, value);
if(!comment->value)
{
AXIS2_FREE(env->allocator, comment);
- AXIS2_FREE(env->allocator, (*node));
+ axiom_node_free_tree(*node, env);
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create comment value");
return NULL;
}
}
+ else
+ {
+ comment->value = NULL;
+ }
axiom_node_set_data_element((*node), env, comment);
axiom_node_set_node_type((*node), env, AXIOM_COMMENT);
@@ -83,14 +86,11 @@ axiom_comment_free(
axiom_comment_t * comment,
const axutil_env_t * env)
{
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
if(comment->value)
{
AXIS2_FREE(env->allocator, comment->value);
}
AXIS2_FREE(env->allocator, comment);
- return;
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
@@ -98,7 +98,6 @@ axiom_comment_get_value(
axiom_comment_t * comment,
const axutil_env_t * env)
{
- AXIS2_ENV_CHECK(env, NULL);
return comment->value;
}
@@ -108,7 +107,6 @@ axiom_comment_set_value(
const axutil_env_t * env,
const axis2_char_t * value)
{
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
if(comment->value)
{
@@ -131,7 +129,6 @@ axiom_comment_serialize(
const axutil_env_t * env,
axiom_output_t * om_output)
{
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE);
if(comment->value)
diff --git a/axiom/src/om/om_element.c b/axiom/src/om/om_element.c
index 7885c83..69e5104 100644
--- a/axiom/src/om/om_element.c
+++ b/axiom/src/om/om_element.c
@@ -1551,7 +1551,6 @@ axiom_element_create_str(
{
axiom_node_add_child(parent, env, (*node));
}
- axiom_node_set_complete((*node), env, AXIS2_FALSE);
axiom_node_set_node_type((*node), env, AXIOM_ELEMENT);
axiom_node_set_data_element((*node), env, element);
diff --git a/axiom/src/om/om_namespace.c b/axiom/src/om/om_namespace.c
index 2d9df2f..24d80a4 100644
--- a/axiom/src/om/om_namespace.c
+++ b/axiom/src/om/om_namespace.c
@@ -301,7 +301,6 @@ axiom_namespace_create_str(
{
axiom_namespace_t *om_namespace = NULL;
- AXIS2_ENV_CHECK(env, NULL);
if(!uri)
{
uri = axutil_string_create(env, "");
diff --git a/axiom/src/om/om_stax_builder.c b/axiom/src/om/om_stax_builder.c
index 0052338..6f43bf0 100644
--- a/axiom/src/om/om_stax_builder.c
+++ b/axiom/src/om/om_stax_builder.c
@@ -260,6 +260,7 @@ axiom_stax_builder_create_om_text(
if(!parent)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_LAST_NODE_NULL, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create OM Text without a node");
return NULL;
}
@@ -267,6 +268,7 @@ axiom_stax_builder_create_om_text(
if(!temp_value)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_VALUE_NULL, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid OM Text value");
return NULL;
}
@@ -292,12 +294,14 @@ axiom_stax_builder_create_om_text(
axiom_text_create_str(env, parent, temp_value_str, &node);
axutil_string_free(temp_value_str, env);
- if(node)
+ if(!node)
{
- axiom_node_set_complete(node, env, AXIS2_TRUE);
- om_builder->lastnode = node;
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create axiom_text");
+ return NULL;
}
+ axiom_node_set_complete(node, env, AXIS2_TRUE);
+ om_builder->lastnode = node;
return node;
}
@@ -483,13 +487,7 @@ axiom_stax_builder_create_om_comment(
{
axiom_node_t *comment_node = NULL;
axis2_char_t *comment_value = NULL;
-
- if(!om_builder->lastnode)
- {
- /* if the comment is at the root level, we will omit it */
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Top level comment is ignored");
- return NULL;
- }
+ axiom_node_t *parent = NULL;
comment_value = axiom_xml_reader_get_value(om_builder->parser, env);
if(!comment_value)
@@ -502,20 +500,22 @@ axiom_stax_builder_create_om_comment(
if(axiom_node_is_complete(om_builder->lastnode, env))
{
/* Last node is completed means, this node should be a sibling of last node */
- axiom_node_t *parent = axiom_node_get_parent(om_builder->lastnode, env);
- axiom_comment_create(env, parent, comment_value, &comment_node);
- axiom_node_set_next_sibling(om_builder->lastnode, env, comment_node);
- axiom_node_set_previous_sibling(comment_node, env, om_builder->lastnode);
+ parent = axiom_node_get_parent(om_builder->lastnode, env);
}
else
{
/* this node should be a child of last node */
- axiom_comment_create(env, om_builder->lastnode, comment_value, &comment_node);
- axiom_node_set_first_child(om_builder->lastnode, env, comment_node);
- axiom_node_set_parent(comment_node, env, om_builder->lastnode);
+ parent = om_builder->lastnode;
}
+ axiom_comment_create(env, parent, comment_value, &comment_node);
axiom_xml_reader_xml_free(om_builder->parser,env,comment_value);
+ if(!comment_node)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create axiom element");
+ return NULL;
+ }
+
axiom_node_set_builder(comment_node, env, om_builder);
om_builder->element_level++;
om_builder->lastnode = comment_node;
@@ -596,8 +596,7 @@ axiom_stax_builder_end_element(
if(axiom_node_is_complete(om_builder->lastnode, env))
{
/* Last node completed means, this end element should be parent of the last node. */
- axiom_node_t *parent = NULL;
- parent = axiom_node_get_parent(om_builder->lastnode, env);
+ axiom_node_t *parent = axiom_node_get_parent(om_builder->lastnode, env);
if(parent)
{
axiom_node_set_complete(parent, env, AXIS2_TRUE);
@@ -610,7 +609,7 @@ axiom_stax_builder_end_element(
}
/* if we finish building the root node, then we can set the complete status of om_builder */
- if(om_builder->root_node && axiom_node_is_complete(om_builder->root_node, env))
+ if(axiom_node_is_complete(om_builder->root_node, env))
{
om_builder->done = AXIS2_TRUE;
}
@@ -661,7 +660,6 @@ axiom_stax_builder_next_with_token(
if(!axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE))
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating start element");
- /* error is set in the create_om_element method. No need to set here */
return -1;
}
break;
@@ -677,7 +675,8 @@ axiom_stax_builder_next_with_token(
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating empty element");
return -1;
}
- /* Let this to fall to AXIOM_XML_READER_END_ELEMENT case as well, since empty element
+ /* Note that we don't have a break here.
+ * Let this to fall to AXIOM_XML_READER_END_ELEMENT case as well, since empty element
* = start element logic + end element logic */
}
case AXIOM_XML_READER_END_ELEMENT:
@@ -717,9 +716,20 @@ axiom_stax_builder_next_with_token(
}
case AXIOM_XML_READER_COMMENT:
{
- if(axiom_stax_builder_create_om_comment(om_builder, env))
+ /* if the comment is at the root level, we will omit it */
+ if(om_builder->lastnode)
{
- axiom_stax_builder_end_element(om_builder, env);
+ axis2_status_t status = AXIS2_FAILURE;
+ if(axiom_stax_builder_create_om_comment(om_builder, env))
+ {
+ status = axiom_stax_builder_end_element(om_builder, env);
+ }
+
+ if(status != AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating axiom comment");
+ return -1;
+ }
}
break;
}
diff --git a/axiom/src/om/om_text.c b/axiom/src/om/om_text.c
index 453c395..6328dd3 100644
--- a/axiom/src/om/om_text.c
+++ b/axiom/src/om/om_text.c
@@ -43,7 +43,6 @@ struct axiom_text
/** The following fields are for MTOM */
axis2_char_t *mime_type;
axis2_bool_t optimize;
- const axis2_char_t *localname;
axis2_bool_t is_binary;
axis2_bool_t is_swa;
axis2_char_t *content_id;
@@ -80,7 +79,6 @@ axiom_text_create(
om_text->mime_type = NULL;
om_text->optimize = AXIS2_FALSE;
- om_text->localname = "Include";
om_text->is_binary = AXIS2_FALSE;
om_text->is_swa = AXIS2_FALSE;
om_text->content_id = NULL;
@@ -341,14 +339,6 @@ axiom_text_set_is_binary(
return AXIS2_SUCCESS;
}
-AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
-axiom_text_get_localname(
- axiom_text_t * om_text,
- const axutil_env_t * env)
-{
- return om_text->localname;
-}
-
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axiom_text_get_content_id(
axiom_text_t * om_text,
@@ -383,7 +373,7 @@ axiom_text_serialize_start_part(
axis2_char_t *prefix = NULL;
const axis2_char_t *local_name = NULL;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- local_name = axiom_text_get_localname(om_text, env);
+ local_name = "Include";
om_text->ns = axiom_namespace_create(env, "http://www.w3.org/2004/08/xop/include", "xop");
@@ -552,35 +542,26 @@ axiom_text_create_str(
axiom_node_t ** node)
{
axiom_text_t *om_text = NULL;
- AXIS2_ENV_CHECK(env, NULL);
AXIS2_PARAM_CHECK(env->error, node, NULL);
*node = axiom_node_create(env);
-
if(!(*node))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create node needed by om text");
return NULL;
}
+
om_text = (axiom_text_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_text_t));
if(!om_text)
{
AXIS2_FREE(env->allocator, *node);
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create om text");
return NULL;
}
- om_text->mime_type = NULL;
- om_text->optimize = AXIS2_FALSE;
- om_text->localname = "Include";
- om_text->is_binary = AXIS2_FALSE;
- om_text->content_id = NULL;
- om_text->om_attribute = NULL;
- om_text->value = NULL;
- om_text->ns = NULL;
- om_text->data_handler = NULL;
- om_text->mime_type = NULL;
-
+ memset(om_text, 0, sizeof(axiom_text_t));
if(value)
{
om_text->value = axutil_string_clone(value, env);
@@ -588,7 +569,6 @@ axiom_text_create_str(
axiom_node_set_data_element((*node), env, om_text);
axiom_node_set_node_type((*node), env, AXIOM_TEXT);
- axiom_node_set_complete((*node), env, AXIS2_FALSE);
if(parent && axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT)
{