Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

My final entry :)

by PhiRatE (Monk)
on Nov 15, 2002 at 12:21 UTC ( [id://213126]=note: print w/replies, xml ) Need Help??


in reply to Efficient run determination.

use Inline C => <<'END_OF_C_CODE'; void p_process_2(SV *svv) { char prev = 0; long count = 0; long i=0; long len = SvCUR(svv); AV *array; AV *list; char *s = SvPV(svv, len); Inline_Stack_Vars; Inline_Stack_Reset; list = newAV(); av_extend(list, 500); prev = *s; for (i=0; i<len; i++) { if (prev == *s) { count++; } else { array = newAV(); av_push(array,newSVpvn(&prev,1)); av_push(array,newSViv(i-count)); av_push(array,newSViv(count)); av_push(list,newRV_inc(array)); prev = *s; count=1; } s++; } Inline_Stack_Push(newRV_inc(list)); Inline_Stack_Done; } END_OF_C_CODE

Featuring no problems with null chars (binary clean), array pre-extension and the fastest performance so far :)

Its kinda like golf with benchmarks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://213126]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found