New LagartoParser constructor parameter "emitStrings"

8 views
Skip to first unread message

BloodySmartie

unread,
Dec 5, 2014, 4:49:07 AM12/5/14
to jod...@googlegroups.com
Hi Jodders,

after switching to Jodd 3.6.3(from, I think, some 3.5.x version), I've noticed that the constructor of LagartoParser was enhanced by the new parameter emitStrings. I could find this parameter in the JavaDoc, but there's no explanation. So, what does it do? :)

Thanks & best wishes,

David


jodder

unread,
Dec 5, 2014, 6:24:28 AM12/5/14
to jod...@googlegroups.com
Ha, you gonna love this :)

Its all about performances;)

Lagarto parser emits all the text as CharSequence. By default, we are using CharBuffer for implementation. If the CarSequence interface works for you, then you are set - and you will have great performances.

However, sometimes CharSequence is not enough. For example, to build our DOM we store all the texts as Strings. Now, we could do `toString` on the char buffers, but overall that is less performant - because we are first creating char buffer and then strings. Therefore, if you emit strings (set it to true), the implementation for `CharSequence` is going to be a String, and calling toString() on it (to get String type) will have no performance penalties.

That flag determines the implementation of CharSequence, thats al :)

And you are right, this is important, should go to the docs ;)

BloodySmartie

unread,
Dec 9, 2014, 7:14:18 AM12/9/14
to jod...@googlegroups.com
Thanks, a lot - that's right, I like it!
Reply all
Reply to author
Forward
0 new messages