Skip to content

Commit

Permalink
lexical scope avoidence optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ugexe committed Jan 12, 2013
1 parent d7064a2 commit 63bd288
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Changes
@@ -1,5 +1,12 @@
Revision history for Perl module Text::Levenshtein::Damerau::XS

2.3 ?
- bulk88 optimizations
- Removed lexicals from XS.pm

2.2 Thu Jan 10 23:52:34 2013
- NO_XSLOCKS to let malloc work correctly

2.1 Tue Jan 08 20:18:02 2013
- Fixed pod error
- Updated docs
Expand Down
4 changes: 2 additions & 2 deletions XS.xs
Expand Up @@ -34,9 +34,9 @@ PPCODE:

//char *packedSource;
//char type = 'U';
//packedSource = SvPVX(ST(0));
//packedSource = SvPVX(arraySource);
//PUTBACK;
//unpackstring(&type, &type+1, packedSource, packedSource + SvCUR(ST(0)), 0);
//unpackstring(type, type+1, packedSource, packedSource + SvCUR(arraySource), 0);
//SPAGAIN;


Expand Down
7 changes: 7 additions & 0 deletions damerau-int.c
Expand Up @@ -11,9 +11,16 @@ struct dictionary{
unsigned int key;
unsigned int value;
struct dictionary* next;
struct dictionary* prev;
};
typedef struct dictionary item;

struct dictionary_list{
struct dictionary* first;
struct dictionary* last;
};
typedef struct dictionary_list item_list;

static __inline item* push(unsigned int key,item* curr){
item* head;
head = malloc(sizeof(item));
Expand Down
14 changes: 4 additions & 10 deletions lib/Text/Levenshtein/Damerau/XS.pm
Expand Up @@ -5,7 +5,7 @@ require Exporter;
*import = \&Exporter::import;
require DynaLoader;

$Text::Levenshtein::Damerau::XS::VERSION = '2.1';
$Text::Levenshtein::Damerau::XS::VERSION = '2.3';

DynaLoader::bootstrap Text::Levenshtein::Damerau::XS $Text::Levenshtein::Damerau::XS::VERSION;

Expand All @@ -18,15 +18,7 @@ DynaLoader::bootstrap Text::Levenshtein::Damerau::XS $Text::Levenshtein::Damerau
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking

sub xs_edistance {
# Wrapper for XS cxs_edistance function
my $str1 = shift;
my $str2 = shift;
my $maxd = shift || 0;

my @arr1 = unpack 'U*', $str1;
my @arr2 = unpack 'U*', $str2;

return cxs_edistance( \@arr1, \@arr2, $maxd );
return cxs_edistance( [unpack('U*', shift)], [unpack('U*',shift)], shift || 0);
}


Expand All @@ -50,7 +42,9 @@ Text::Levenshtein::Damerau::XS - XS Damerau Levenshtein edit distance.
Returns the true Damerau Levenshtein edit distance of strings with adjacent transpositions. XS implementation (requires a C compiler). Works correctly with utf8.
use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
use utf8;
xs_edistance('ⓕⓞⓤⓡ','ⓕⓤⓞⓡ'),
# prints 1
Expand Down

0 comments on commit 63bd288

Please sign in to comment.