yarffaJ nalA (jnala) wrote in lj_dev,
yarffaJ nalA

HTML in strings, part two

See http://www.livejournal.com/talkread.bml?itemid=4438419 for part 1.
This is probably of little interest to most readers, so, cut:

While profiling the code, I discovered the XML::Generator was, in fact, a pig. I wrote my own module to do the same thing (50 lines of code, 20 lines of constant declarations) and it's 10 times faster than XML::Generator, and 2.5 times faster than the comparable functions in CGI.pm. It's part of the userinfo patch, as LJ::TagGenerator.

Anyway, printing a test table with lots of nested function calls and hashrefs being turned into attributes and such takes under 0.3ms with the new module. I don't think that's worth worrying about, and if we decide it is, the design of the new module would allow a drop-in replacement using a source filter that would eliminate all runtime overhead by evaluating the tag-generation functions at compile-time.

As for readability, generating a <TR> tag (for example) is now done via TR() rather than $xg->tr(), which should take care of one of the concerns people have.

It's there if you want it. If you don't want it, don't use it. But I'm pretty certain I'll be using it in my changes and additions to the code from here on.

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded