Parsing null terminated strings in a binary.
Fri Jan 14 11:15:23 CET 2005
Then it might be worth the effort to hipe compile the lists and string
modules, if it is possible. Instead of hoping lists:sublist to become
By the way, lists:member/2, lists:reverse/2, lists:keymember/3,
lists:append/2 (++), lists:subtract/2 (--) and lists:keysearch/3
(and also erlang:length/1, erlang:hd/1, erlang:tl/1
as well as erlang:list_to_tuple/1 and erlang:tuple_to_list/1 and such)
are BIFs, if you did not already know that.
james.hague@REDACTED (James Hague) writes:
> Raimo Niskanen wrote
> >This will not build any sub-binaries until the zero is found.
> As an aside, I have become enamored of this style of programming even
> for processing lists. For example, consider the problem of parsing a
> number out of a string. I count the number of elements that are ASCII
> digits, then when I don't find any more digits I grab all of them at
> once with lists:sublist. This hides all of the list building inside
> lists:sublist. I won't argue that this is faster, because it is
> certainly somewhat slower than building the list as you go (I did some
> timings). But it opens the door for a faster implementation of
> lists:sublist, possibly as a BIF, which somehow pleases me even though
> I don't ever expect it to happen.
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions