Subject: | clone() not working properly |
Hi there!
Thank you so much for such a nice module - creating CRC digest was never
this easy :)
I'm having some trouble with the clone() method, though. It appears the
cloned data comes with a bogus digest:
--------------8<--------------
perl -MDigest::CRC -E 'my $original = Digest::CRC->new; $original->add(
q[I can has Digest?] ); my $cloned = $original->clone; say q[original: ]
. $original->hexdigest; say q[cloned: ] . $cloned->hexdigest'
original: bb28461d
cloned: ffffffff
-------------->8--------------
I tried dumping them with Data::Printer and the only difference seems to
be that the $self->{_tab} internal structure is missing from the cloned
version. In fact, if I break encapsulation and copy it through, I get
the expected result:
--------------8<--------------
perl -MDigest::CRC -E 'my $original = Digest::CRC->new; $original->add(
q[I can has Digest?] ); my $cloned = $original->clone; $cloned->{_tab} =
[ @{$original->{_tab}} ]; say q[original: ] . $original->hexdigest; say
q[cloned: ] . $cloned->hexdigest;'
original: bb28461d
cloned: bb28461d
-------------->8--------------
I'm not writing a patch though, because I couldn't see the $self->{_tab}
structure being created during neither the new() nor the add() method
calls, so I'm not confident enough that simply copying it over isn't
going to break anything.
Thanks!