Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.91k stars 542 forks source link

[feature] additional internal OPs for standard string manipulation #17188

Closed toddr closed 4 years ago

toddr commented 4 years ago

There are times where C level string manipulation is faster than doing a regex.

It would sometimes be faster to be able to run things like

strcmp(...)
strncasecmp(...)

also tr/// is sometimes used as a faster regex.

@lightsey will provide more details

dur-randir commented 4 years ago

Why do those ops need to be internal, if 'index' is already a 'public' OP? This is either a further regex engine optimization, or a new optree rewrite 'rule' on the peephole optimizer level (but it's a mess).

demerphq commented 4 years ago

On Sun, 20 Oct 2019, 15:30 Todd Rinaldo, notifications@github.com wrote:

There are times where C level string manipulation is faster than doing a regex.

It would sometimes be faster to be able to run things like

strcmp(...) strncasecmp(...)

The perl version strcmp is called "cmp" and is likely to be only faster than cmp if it doesn't handle all the edge cases properly, eg utf8 strings.

also tr/// is sometimes used as a faster regex

tr really shouldn't be faster than the regex engine, and/or perl should silently optimise one into the other where it makes sense

For those that want them it's trivial to write an XS module that exposes them to perl code. I don't think they are appropriate for perl internals as is however.

Yves