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

Re: Another optimization question: bsearch()

Thread Previous | Thread Next
From:
Craig A. Berry
Date:
March 1, 2010 14:45
Subject:
Re: Another optimization question: bsearch()
Message ID:
c9ab31fc1003011445t46c6950ev99bb90521c130f77@mail.gmail.com
On Mon, Mar 1, 2010 at 12:43 PM, karl williamson
<public@khwilliamson.com> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About