DraqueT / PolyGlot

PolyGlot is a conlang construction toolkit.
MIT License
389 stars 44 forks source link

Draft: optimize logic of custom SAX handler #1187

Closed pe1uca closed 1 year ago

pe1uca commented 2 years ago

1229 needs to be merged first.

As seen in this tutorial the characters method of a custom handler should only append the characters being processed in that pass, the logic to update the properties of generated object should be handled in the endElement method.

This cuts down the code needed as it removed the flags that were being set in the startElement method.
Also improves run time as it cuts down on String object creations with new String and concatenation.

Now only special cases are handled in these two methods (startElement and characters)
Mainly the clean up of buffers and the set of tags with mixed content.

TrapinchO commented 2 years ago

Why not replace the else-ifs with a switch?

pe1uca commented 1 year ago

A little bit late to responde you @TrapinchO but: I wanted to minimize the changes so the PR is easier to process.
At a later point we can refactor for optimization, this one is focused on cleaning up the code.

TrapinchO commented 1 year ago

A little bit late to responde you @TrapinchO but: I wanted to minimize the changes so the PR is easier to process. At a later point we can refactor for optimization, this one is focused on cleaning up the code.

just a little bit late :) that makes sense, thanks!

DraqueT commented 1 year ago

Heyo! I feel bad closing this PR since it was such a significant cleanup, but the DOM parser is just a lot more manageable, and has replaced the SAX parser at this point. Thank you for the effort that went in here though!