Philip Mak wrote:
>
> I have a page on my website that prints a plain text file in HTML. So, it
> does something like this:
>
> print "<PRE>";
> open(FANFIC, "$file") or print "File not found: $!\n";
> print Apache::Util::escape_html($_) while (<FANFIC>);
> close(FANFIC);
> print "</PRE>\n";
>
> I used to use $Server->HTMLEncode() instead of
> Apache::Util::escape_html(), but I noticed that
> Apache::Util::escape_html() could do it in 40 requests per second, as
> compared to 30. AFAIK these two functions are semantically equivalent, so
> perhaps $Server->HTMLEncode should use the same code as
> Apache::Util::escape_html, which is compiled C code I believe?
>
Calling a function like &Object:funct() is faster than
calling it OO style like $Object->func() because of the runtime
lookup perl has to do to resolve $Object->func(). It may
be that if you were calling &Apache::ASP::Server($Server, $html)
that it would be near as fast.
But even faster is just escape once ...
my $data = join('', <FANFIC>);
$data = $Server->HTMLEncode($data);
I could probably extend $Server->HTMLEncode to take
a \$data scalar ref to save on the buffer copy too
which might help some, but hardly any I'm guessing.
I'd like to stay away from the Apache utility functions
for portability concerns. Right now, it would be fairly
trivial to port Apache::ASP to another web server, like
I have it working under raw CGI mode, but if I start
adding in those, it makes things more complex.
-- Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]