develooper Front page | perl.perl5.porters | Postings from March 2010

Re: Another optimization question: bsearch()

Thread Previous | Thread Next
Craig A. Berry
March 1, 2010 14:45
Re: Another optimization question: bsearch()
Message ID:
On Mon, Mar 1, 2010 at 12:43 PM, karl williamson
<> wrote:
> Jarkko a long time ago that swashes and regex character classes should be
> replaced by inversion lists for efficiency.
> Inversion lists can be searched binarily.  bsearch() is a standard C library
> routine, but the only mention of it in Perl is in the POSIX module where it
> says it is not furnished.  This makes me think there must be a problem with
> using the library routine.  Is there?

It takes a pointer to a call-back function for doing comparisons.  To
include it in the POSIX extension I guess you'd have to have a generic
call-back in C that knows how to invoke a user-supplied call-back in
Perl and does the right thing with the return values, disallows or
handles multiple simultaneous searches, etc.  Sounds like work.  But
that's unrelated to using it for internal implementations, which I
can't think of any reason not to do.

I have it in a VAX C manual dated March 1987 with exactly the same
prototype as the standard now specifies.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About