in reply to Re: Optimizing a string processing sub
in thread Optimizing a string processing sub
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
|
|---|