sbcgua / ajson

Yet another json parser serializer for ABAP
MIT License
49 stars 15 forks source link

Performance: Speed-up parsing #143

Closed mbtools closed 1 year ago

mbtools commented 1 year ago

Using string instead of stack to handle path makes benchmark 3.4% faster.

You could get another 2-3% by removing the consistency check in closing a node:

Before:

        when if_sxml_node=>co_nt_element_close.
          data lo_close type ref to if_sxml_close_element.
          lo_close ?= lo_node.

          read table mt_stack index 1 into lr_stack_top.
          delete mt_stack index 1.
          if lo_close->qname-name <> lr_stack_top->type.
            raise( 'Unexpected closing node type' ).
          endif.

After:

        when if_sxml_node=>co_nt_element_close.
          delete mt_stack index 1.
sbcgua commented 1 year ago

image

Yeap ~2%

Consistency check is important, let it stay. Don't trust external data :)

mbtools commented 1 year ago

I think inconsistencies already lead to cx_sxml_parse_error or cx_sxml_error but maybe there are cases sxml does not catch.