Here's your ...:
use Inline C => <<EOT; UV score(char* a, char* b) { /* it doesn't like const... */ char mark[256] = { 0 }, * i; UV sc = 0; for(i = a; *i; mark[*i++] = 1); for(i = b; *i; i++) if(mark[*i]) sc += mark[*i]--; return sc; } EOT
Yep, you're right, it won't work for Unicode. Modification to do so is left as an excercise for the diligent student.
czth
In reply to Re: Re: Optimizing a string processing sub
by czth
in thread Optimizing a string processing sub
by spurperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |