Patch for strstr_binary

Dave Smith dizzyd@REDACTED
Tue Dec 13 01:21:25 CET 2005


Greetings,

I'm not sure how the list feels about patches for new BIFs, but I'd  
like to share a patch for OTP R10B8 to speed up string/binary  
processing. In particular, I needed a way to do the equivalent of  
string:str() on a binary object, and it needed to be fast (I'm  
parsing a very large number of HTTP connections). Initially I did all  
my parsing in a C driver/port but got tired of dealing with memory  
management and other wonderful aspects of C. Some profiling of a  
native Erlang version of my parsing code yielded that a fast  
string:str function on binaries would get me nearly back to C-speed,  
so that's how I came up with this patch.

I understand completely if the erlang group doesn't wish to  
incorporate this patch into the core distribution, but I do hope it's  
at least considered. The code has been (lightly) load tested on Mac  
OSX and smoke tested on Linux (32-bit). I doubt it will work on  
win32, as it uses a memcmp() function...but it should be easy to  
port.  I welcome any feedback and comments -- this is my first BIF. :)

Cheers!

D.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strstr_binary.patch
Type: application/octet-stream
Size: 1482 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20051212/8ba80db2/attachment.obj>
-------------- next part --------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20051212/8ba80db2/attachment.bin>


More information about the erlang-questions mailing list