Re: Sort hash keys in C...

2008-05-24 Thread Rudolf Lippan
On Mon, 19 May 2008 10:15:26 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > > On Fri, May 16, 2008 at 01:45:51AM +0100, Rudolf Lippan wrote: >> On Thu, 15 May 2008 13:21:34 +0100, Tim Bunce <[EMAIL PROTECTED]> > wrote: >> > It would be good to add a clear comment somewhere that the pointers in >>

Re: Sort hash keys in C...

2008-05-19 Thread Tim Bunce
On Fri, May 16, 2008 at 01:45:51AM +0100, Rudolf Lippan wrote: > On Thu, 15 May 2008 13:21:34 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > > I'm sorry for the delay in responding Rudy. > > > > On Wed, May 07, 2008 at 02:34:43AM -0400, Rudy Lippan wrote: > > >> use Scalar::Util qw(looks_like_num

Re: Sort hash keys in C...

2008-05-15 Thread Rudolf Lippan
On Thu, 15 May 2008 13:21:34 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > I'm sorry for the delay in responding Rudy. > > On Wed, May 07, 2008 at 02:34:43AM -0400, Rudy Lippan wrote: > >> use Scalar::Util qw(looks_like_number); >> sub _get_sorted_hash_keys { >> my ($hash_ref, $sort_type)

Re: Sort hash keys in C...

2008-05-15 Thread Tim Bunce
I'm sorry for the delay in responding Rudy. On Wed, May 07, 2008 at 02:34:43AM -0400, Rudy Lippan wrote: I think it would be better to keep appending to an sv rather than try to pre-guess the size. That would avoid the need for the malloc/realloc/free. >>> Well it would avoid my having t

Re: Sort hash keys in C...

2008-04-29 Thread Tim Bunce
On Tue, Apr 29, 2008 at 01:56:26AM +0100, Rudolf Lippan wrote: > > On Mon, 28 Apr 2008 23:51:09 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > > On Mon, Apr 28, 2008 at 03:24:10PM +0100, Rudolf Lippan wrote: > > >> Oh, And is there a way to attach a string to an SV w/o copying it? > > > > Not sur

Re: Sort hash keys in C...

2008-04-28 Thread Rudolf Lippan
On Mon, 28 Apr 2008 23:51:09 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > On Mon, Apr 28, 2008 at 03:24:10PM +0100, Rudolf Lippan wrote: >> > > Do you have svn? You could post patches from 'svn diff'. > See http://search.cpan.org/~timb/DBI/DBI.pm#CONTRIBUTING I am more of an SVK person, but sv

Re: Sort hash keys in C...

2008-04-28 Thread Tim Bunce
On Mon, Apr 28, 2008 at 03:24:10PM +0100, Rudolf Lippan wrote: > > > On Thu, 24 Apr 2008 13:31:47 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > > Hi Tim, > > > So I'd be happy to see an API like this: > > > > SV *_concat_hash_sorted( HV *hv, char *kv_sep, char *pair_sep, SV > > *value_format,

Re: Sort hash keys in C...

2008-04-28 Thread Rudolf Lippan
On Thu, 24 Apr 2008 13:31:47 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: Hi Tim, > So I'd be happy to see an API like this: > > SV *_concat_hash_sorted( HV *hv, char *kv_sep, char *pair_sep, SV > *value_format, SV *sort_type) > Attached is the latest draft of _concat_hash_sorted(). I cleaned

Re: Sort hash keys in C...

2008-04-24 Thread Rudolf Lippan
On Thu, 24 Apr 2008 13:31:47 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > So I'd be happy to see an API like this: > > SV *_concat_hash_sorted( HV *hv, char *kv_sep, char *pair_sep, SV > *value_format, SV *sort_type) > > The kv_sep & pair_sep params could be SV*'s if that's easier to implemen

Re: Sort hash keys in C...

2008-04-24 Thread Tim Bunce
On Thu, Apr 24, 2008 at 12:50:09AM +0100, Rudolf Lippan wrote: > > > On Wed, 23 Apr 2008 09:34:13 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > > > Here's a more refined and detailed outline. It's evolved from one I > > aka more involved ;) Naturally ;) > > sub _concat_hash_sorted { > >

Re: Sort hash keys in C...

2008-04-23 Thread Rudolf Lippan
On Wed, 23 Apr 2008 09:34:13 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > Here's a more refined and detailed outline. It's evolved from one I aka more involved ;) > sub _concat_hash_sorted { > my ( $hash_ref, $kv_separator, $pair_separator, $value_format, > $sort_type ) = @_; > # $va

Re: Sort hash keys in C...

2008-04-23 Thread Tim Bunce
On Wed, Apr 23, 2008 at 12:17:42AM +0100, Rudolf Lippan wrote: > On Tue, 22 Apr 2008 11:24:17 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > > Any volunteers, either for both or just the sort function? > > Hi Tim, > > I would be happy to take a crack at them tomorrow -- actually I have a > rough d

Re: Sort hash keys in C...

2008-04-22 Thread Rudolf Lippan
On Tue, 22 Apr 2008 11:24:17 +0100, Tim Bunce <[EMAIL PROTECTED]> wrote: > The DBI needs to sort the keys in %$attr for connect_cached and > prepare_cached to ensure a canonical cache key is generated. > > Currently this is done in perl and is relatively expensive: > > my @attr_keys = ($attr

Sort hash keys in C...

2008-04-22 Thread Tim Bunce
The DBI needs to sort the keys in %$attr for connect_cached and prepare_cached to ensure a canonical cache key is generated. Currently this is done in perl and is relatively expensive: my @attr_keys = ($attr) ? sort keys %$attr : (); my $key = do { local $^W; # silence undef warnings