[ircd-ratbox] IRC packet parsing.
Paul-Andrew Joseph Miseiko
esoteric at teardrop.ca
Sat Feb 7 23:36:48 EST 2004
I just thought of an interesting way to parse IRC packets and figured I
would post it here to get some feedback.
First, according to the RFC an IRC packet is delimited by a \r\n sequence.
Therefore an optimal search for the nth character of the sequence would
result in started at the nth position in a contiguous buffer and skipping
nth bytes when the delimiting character is not found.
To put it in pure English, we would start at the second byte of the buffer,
and increment our search by 2 rather then 1 if no "\n" is found. If a "\n"
is found we can verify the previous byte is a "\r" character and then we
have the bounds of our IRC packet. Obviously you just reduced the number of
comparison operations by a factor of two making it a O(n/2) operation to
search for the bounds of a IRC packet in a contiguous buffer space.
I see no particular reason why this will not work, hence why I have decided
to post here for some scrutinizing. (I probably would have messaged Sarisa
if I could remember his email address:-)).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ircd-ratbox