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 the keys

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_number); sub

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 to do it;

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-04-29 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 svk is

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 sure what you

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 up

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, SV *sort_type)

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 implement.

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

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) ?