axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r817159 - in /webservices/axis2/trunk/c/guththila/src: guththila_stack.c guththila_token.c guththila_xml_parser.c
Date Mon, 21 Sep 2009 05:21:04 GMT
Author: shankar
Date: Mon Sep 21 05:21:04 2009
New Revision: 817159

URL: http://svn.apache.org/viewvc?rev=817159&view=rev
Log:
improving performance

Modified:
    webservices/axis2/trunk/c/guththila/src/guththila_stack.c
    webservices/axis2/trunk/c/guththila/src/guththila_token.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_parser.c

Modified: webservices/axis2/trunk/c/guththila/src/guththila_stack.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_stack.c?rev=817159&r1=817158&r2=817159&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_stack.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_stack.c Mon Sep 21 05:21:04 2009
@@ -60,7 +60,7 @@
 {
     if(stack->top > 0)
     {
-        return stack->data[stack->top-- - 1];
+        return stack->data[--(stack->top)];
     }
     return NULL;
 }
@@ -71,24 +71,21 @@
     void *data,
     const axutil_env_t * env)
 {
-    int i = 0;
-    void **temp = NULL;
-    if(stack->top >= stack->max)
+    int top = stack->top++;
+    if(top >= stack->max)
     {
-
-        temp = (void **)AXIS2_MALLOC(env->allocator, sizeof(void **) * (stack->max
-            += GUTHTHILA_STACK_DEFAULT));
-        for(i = 0; i < stack->top; i++)
+        void **temp = NULL;
+        int i = 0;
+        temp = (void **)AXIS2_MALLOC(env->allocator, sizeof(void **) * (stack->max
*= 2));
+        for(i = 0; i < top; ++i)
         {
             temp[i] = stack->data[i];
         }
         AXIS2_FREE(env->allocator, stack->data);
         stack->data = temp;
-        if(!stack->data)
-            return GUTHTHILA_FAILURE;
     }
-    stack->data[stack->top] = data;
-    return stack->top++;
+    stack->data[top] = data;
+    return top;
 }
 
 void *GUTHTHILA_CALL

Modified: webservices/axis2/trunk/c/guththila/src/guththila_token.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_token.c?rev=817159&r1=817158&r2=817159&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_token.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_token.c Mon Sep 21 05:21:04 2009
@@ -31,35 +31,41 @@
     const axutil_env_t * env)
 {
     int i = 0;
-    int cur = 0;
-    int cur_cap = 0;
-    guththila_token_t ** list = NULL;
+
     if(tok_list->cur_list < tok_list->no_list - 1)
     {
-        cur = ++tok_list->cur_list;
-        cur_cap = tok_list->capacity[cur - 1] * 2;
-        tok_list->list[cur] = (guththila_token_t *)AXIS2_MALLOC(env->allocator,
+        int cur = ++tok_list->cur_list;
+        int cur_cap = tok_list->capacity[cur - 1] * 2;
+        guththila_token_t *list = (guththila_token_t *)AXIS2_MALLOC(env->allocator,
             sizeof(guththila_token_t) * cur_cap);
-        for(i = 0; i < cur_cap; i++)
+        for(i = 0; i < cur_cap; ++i)
         {
-            guththila_stack_push(&tok_list->fr_stack, &tok_list->list[cur][i],
env);
+            guththila_stack_push(&tok_list->fr_stack, &list[i], env);
         }
         tok_list->capacity[cur] = cur_cap;
+        tok_list->list[cur] = list;
         return GUTHTHILA_SUCCESS;
     }
     else
     {
+        guththila_token_t ** list = NULL;
+        int *capacity = NULL;
         list = (guththila_token_t **)AXIS2_MALLOC(env->allocator, sizeof(guththila_token_t
*)
             * tok_list->no_list * 2);
+        capacity = (int *)AXIS2_MALLOC(env->allocator, sizeof(int) * tok_list->no_list
* 2);
         if(list)
         {
-            for(i = 0; i <= tok_list->cur_list; i++)
+            int cur_list = tok_list->cur_list;
+            for(i = 0; i <= cur_list; ++i)
             {
                 list[i] = tok_list->list[i];
+                capacity[i] = tok_list->capacity[i];
             }
             tok_list->no_list = tok_list->no_list * 2;
             AXIS2_FREE(env->allocator, tok_list->list);
             tok_list->list = list;
+            AXIS2_FREE(env->allocator, tok_list->capacity);
+            tok_list->capacity = capacity;
             guththila_tok_list_grow(tok_list, env);
         }
     }

Modified: webservices/axis2/trunk/c/guththila/src/guththila_xml_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_parser.c?rev=817159&r1=817158&r2=817159&view=diff
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_parser.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_parser.c Mon Sep 21 05:21:04 2009
@@ -58,6 +58,8 @@
             else\
             {\
                 c = guththila_next_char(m, env);\
+                if(c < 0)\
+                    return -1;\
                 result_found  = 1;\
             }\
         }\
@@ -77,11 +79,13 @@
             --(m->next);\
             if(m->reader->type == GUTHTHILA_MEMORY_READER)\
             {\
-                c = -1;\
+                return -1;\
             }\
             else\
             {\
                 c = guththila_next_char(m, env);\
+                if(c < 0)\
+                    return -1;\
             }\
         }\
     }\
@@ -117,106 +121,70 @@
     guththila_t * m,
     const axutil_env_t * env);
 
+/*
+ * Return non zero value if the given argument is a space. (c < 0x21) is added to improve
the
+ * performance. common case is printable characters. and if given character is printable,
we can
+ * return false immediately.
+ */
+#define GUTHTHILA_IS_SPACE(c) ((c < 0x21) && (c == 0x20 || c == 0xD || c == 0xA
|| c == 0x9))
+
 /* 
  * Read characters until all the white spaces are read.
  */
-#ifndef GUTHTHILA_SKIP_SPACES
-#define GUTHTHILA_SKIP_SPACES(m, c, buffer, data_size, previous_size, _env)while(0x20 ==
c || 0x9 == c || 0xD == c || 0xA == c){GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size,
_env, c);}
-#endif  
+#define GUTHTHILA_SKIP_SPACES(m, c, buffer, data_size, previous_size, _env)while(GUTHTHILA_IS_SPACE(c)){GUTHTHILA_NEXT_CHAR(m,
buffer, data_size, previous_size, _env, c);}
 
-/*
- * Read character including new line until a non white space character is met.
- */
-#ifndef GUTHTHILA_SKIP_SPACES_WITH_NEW_LINE
-#define GUTHTHILA_SKIP_SPACES_WITH_NEW_LINE(m, c, buffer, data_size, previous_size, _env)
while (0x20 == c || 0x9 == c || 0xD == c || 0xA == c || '\n' == c){GUTHTHILA_NEXT_CHAR(m,
buffer, data_size, previous_size, _env, c);}
-#endif  
 
-#ifndef GUTHTHILA_XML_NAME
 #define GUTHTHILA_XML_NAME "xml"
-#endif
 
-#ifndef GUTHTHILA_XML_URI
 #define GUTHTHILA_XML_URI "http://www.w3.org/XML/1998/namespace"
-#endif    
-
-/* 
- * Return the last character that was read
- */
-#ifndef GUTHTHILA_LAST_CHAR
-#define GUTHTHILA_LAST_CHAR(m) (m->buffer.buff + m->buffer.next - 1)
-#endif  
 
 /*
  * Open a token. When we open a token we don't know it's type. We only 
  * set the starting values.
  */
-#ifndef GUTHTHILA_TOKEN_OPEN
 #define GUTHTHILA_TOKEN_OPEN(m, tok, _env)					\
     m->temp_tok = guththila_tok_list_get_token(&m->tokens, _env); \
     m->temp_tok->type = _Unknown; \
     m->temp_tok->_start = (int)m->next; \
     m->last_start = (int)m->next - 1;
 /* We are sure that the difference lies within the int range */
-#endif  
 
 /*
  * Read until we met a = character.
  */
-#ifndef GUTHTHILA_PROCESS_EQU
-#define GUTHTHILA_PROCESS_EQU(m, c, ic, buffer, data_size, previous_size, _env)							\
+#define GUTHTHILA_PROCESS_EQU(m, c, ic, buffer, data_size, previous_size, _env)\
+{\
     GUTHTHILA_SKIP_SPACES(m, c, buffer, data_size, previous_size, _env); \
-    if (0x3D == c) { \
-    GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, _env, ic); \
-    GUTHTHILA_SKIP_SPACES(m, ic, buffer, data_size, previous_size, _env); \
-    }
-#endif  
+    if (c == '=')\
+    { \
+        GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, _env, ic); \
+        GUTHTHILA_SKIP_SPACES(m, ic, buffer, data_size, previous_size, _env); \
+    }\
+}
 
 /*
  * Initialize a attribute to the values given.
  */
-#ifndef GUTHTHILA_ATTRIBUTE_INITIALIZE
 #define GUTHTHILA_ATTRIBUTE_INITIALIZE(_attr, _pref, _name, _val)	\
     (_attr->pref = (_pref)); \
     (_attr->name = (_name)); \
     (_attr->val = (_val));
-#endif  
 
 /*
  * Initialize namespace to the values given.
  */
-#ifndef GUTHTHILA_NAMESPACE_INITIALIZE
 #define GUTHTHILA_NAMESPACE_INITIALIZE(_namesp, _name, _uri)	\
     (_namesp->name = _name); \
     (_namesp->uri = _uri);
-#endif  
-
-/*
- * Return non zero value if the given argument is a space. (c < 0x21) is added to improve
the
- * performance. common case is printable characters. and if given character is printable,
we can
- * return false immediately.
- */
-#ifndef GUTHTHILA_IS_SPACE
-#define GUTHTHILA_IS_SPACE(c) ((c < 0x21) && (c == 0x20 || c == 0xD || c == 0xA
|| c == 0x9))
-#endif  
-
-/*
- * Deterine weather a given character is a valid xml string char.
- */
-#ifndef GUTHTHILA_IS_VALID_STRING_CHAR
-#define GUTHTHILA_IS_VALID_STRING_CHAR(c) (isalpha(c) || '_' == c || ':' == c)
-#endif 
 
 /*
  * Determine weahter a given character is a valid starting char for a xml name.
  */
-#ifndef GUTHTHILA_IS_VALID_STARTING_CHAR
 #define GUTHTHILA_IS_VALID_STARTING_CHAR(c) (isalpha(c) || '_' == c || ':' == c)
-#endif 
 
 /*
  * Initialize the variables in the guththila_t structure.
  */
-#ifndef GUTHTHILA_VARIABLE_INITIALZE
 #define GUTHTHILA_VARIABLE_INITIALZE(m) \
     m->temp_prefix = NULL; \
     m->temp_name = NULL; \
@@ -225,7 +193,6 @@
     m->name = NULL; \
     m->prefix = NULL; \
     m->value = NULL;
-#endif 
 
 /*
  * Initialize the guththila_t structure with the reader. 
@@ -727,7 +694,6 @@
     guththila_elem_namesp_t * nmsp = NULL;
     guththila_token_t * tok = NULL;
     int quote = 0, ref = 0;
-    guththila_char_t c_arra[16] = { 0 };
     int c = -1;
     guththila_attr_t * attr = NULL;
     int size = 0, i = 0, nmsp_counter, loop = 0, white_space = 0;
@@ -796,8 +762,6 @@
             while(isspace(c))
             {
                 GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, c);
-                if(c < 0)
-                    return -1;
             }
             if('<' == c)
             {
@@ -808,20 +772,22 @@
                 return -1;
             }
         }
-        if('<' == c && m->status == S_2)
+        if(m->status != S_2)
+        {
+            return -1;
+        }
+        if(c == '<')
         {
             GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, c);
             if(c != '?' && c != '!' && c != '/')
             {
-                /* We are at the beginig of a xml element */
+                /* We are at the beginning of a xml element */
                 if(GUTHTHILA_IS_VALID_STARTING_CHAR(c))
                 {
                     GUTHTHILA_TOKEN_OPEN(m, tok, env);
                     GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, c);
                     while(!GUTHTHILA_IS_SPACE(c) && c != '>' && c != '/')
                     {
-                        if(c < 0)
-                            return -1;
                         if(c != ':')
                         {
                             GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env,
c);
@@ -876,7 +842,7 @@
                             return GUTHTHILA_START_ELEMENT;
                     }
                     /* We are in the middle of a element */
-                    else if(c != -1)
+                    else
                     {
                         /* Process the attributes */
                         if(GUTHTHILA_IS_VALID_STARTING_CHAR(c))
@@ -886,8 +852,6 @@
                             GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env,
c);
                             while(!GUTHTHILA_IS_SPACE(c) && c != '=')
                             {
-                                if(c < 0)
-                                    return -1;
                                 if(c != ':')
                                 {
                                     GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size,
env, c);
@@ -909,14 +873,12 @@
                         }
                         /* Attribute Value */
                         GUTHTHILA_PROCESS_EQU(m, c, quote, buffer, data_size, previous_size,
env);
-                        if('\'' == quote || '\"' == quote)
+                        if(quote == '\'' || quote == '\"')
                         {
                             GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env,
c);
                             GUTHTHILA_TOKEN_OPEN(m, tok, env);
                             while(c != quote)
                             {
-                                if(c < 0)
-                                    return -1;
                                 GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size,
env, c);
                             }
                             guththila_token_close(m, tok, _attribute_value, 0, env);
@@ -928,11 +890,7 @@
                             return -1;
                         }
                     }
-                    else
-                    {
-                        return -1;
-                    }
-                }
+                } /* for(;;) */
             }
             else if(c == '/')
             {
@@ -945,8 +903,6 @@
                     GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, c);
                     while(!GUTHTHILA_IS_SPACE(c) && c != '>')
                     {
-                        if(c < 0)
-                            return -1;
                         if(c != ':')
                         {
                             GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env,
c);
@@ -1008,6 +964,7 @@
             else if(c == '!')
             {
                 /* Comment */
+                guththila_char_t c_arra[16] = { 0 };
                 if(2 == guththila_next_no_char(m, 0, c_arra, 2, env) && '-' == c_arra[0]
&& '-'
                     == c_arra[1])
                 {
@@ -1044,8 +1001,6 @@
                     GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, c);
                     while('<' != c)
                     {
-                        if(c < 0)
-                            return -1;
                         GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, c);
                     }
                 }
@@ -1060,7 +1015,7 @@
                     return -1;
             }
         }
-        else if(c != '<' && m->status == S_2 && c != -1)
+        else
         {
             /* Text */
             m->guththila_event = GUTHTHILA_CHARACTER;
@@ -1089,7 +1044,7 @@
                             break;
                         }
                     }
-                    while((c != '<') && (c >= 0));
+                    while(c != '<');
                 }
                 else
                 {
@@ -1115,12 +1070,10 @@
                         {
                             GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env,
c);
                         }
-                    }while((c != '<') && (c >= 0));
+                    }while(c != '<');
                 }
             }
-            while((c != '<') && (c >= 0));
-            if(c < 0)
-                return -1;
+            while(c != '<');
             guththila_token_close(m, tok, _text_data, ref, env);
             m->next--;
             if(white_space)
@@ -1142,10 +1095,6 @@
             else
                 return GUTHTHILA_CHARACTER;
         }
-        else
-        {
-            return -1;
-        }
     }
     while(loop);
     return c;
@@ -1184,8 +1133,6 @@
                 GUTHTHILA_TOKEN_OPEN(m, tok, env);
                 while(nc != quote)
                 {
-                    if(nc < 0)
-                        return -1;
                     GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, nc);
                 }
                 guththila_token_close(m, tok, _attribute_value, 0, env);
@@ -1211,8 +1158,6 @@
                 GUTHTHILA_TOKEN_OPEN(m, tok, env);
                 while(nc != quote)
                 {
-                    if(nc < 0)
-                        return -1;
                     GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, nc);
                 }
                 guththila_token_close(m, tok, _attribute_value, 0, env);
@@ -1234,8 +1179,6 @@
                 GUTHTHILA_TOKEN_OPEN(m, tok, env);
                 while(nc != quote)
                 {
-                    if(nc < 0)
-                        return -1;
                     GUTHTHILA_NEXT_CHAR(m, buffer, data_size, previous_size, env, nc);
                 }
                 guththila_token_close(m, tok, _attribute_value, 0, env);



Mime
View raw message