Re: RFC 165 (v1) Allow Varibles in tr///

[email protected] (Bart Lateur)
Newsgroups perl.perl6.language.regex
Organization MediaMind
Message-ID <[email protected]>
On Wed, 30 Aug 2000 00:31:24 -0400, Stephen P. Potter wrote:

>For every tr/// in a program,
>256 bytes have to be allocated?  Even if I only do something like tr/a/A/?
>Is this really the optimal solution for this

Speedwise, it is. You don't have to do any tests on the bytes. All you
have to do is use the ord of the character (the byte value) as an offset
in a table, and replace what you had with what you find in the table. A
test and conditional jump instruction is a lot slower. Some processors,
like Intel's x86, even have a special machine instruction to do that:
XLAT.

And, compared to how much memory perl needs to run anyway, what is 256
bytes? How many tr/// tables do you think you need? Even if it's 100,
you still get only at about 25k of tables, which still isn't that much.

-- 
	Bart.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.