Imported Upstream version 2.04
authorAlexandre Mestiashvili <alex@biotec.tu-dresden.de>
Thu, 6 Mar 2014 16:39:57 +0000 (17:39 +0100)
committerAlexandre Mestiashvili <alex@biotec.tu-dresden.de>
Thu, 6 Mar 2014 16:39:57 +0000 (17:39 +0100)
Changes
Encoder.xs
MANIFEST
META.json [deleted file]
META.yml
author_tools/hobodecoder.pl
lib/Sereal/Encoder.pm
t/100_roundtrip.t [deleted file]
t/101_roundtrip_v1.t [deleted file]
t/700_roundtrip.t [new file with mode: 0644]
t/701_roundtrip_v1.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 23f012b3554d45c097c1575e4b96ff93c55090cd..929482d5f158c5eea3f32a805e19c0e5d5dfe56a 100644 (file)
--- a/Changes
+++ b/Changes
@@ -4,6 +4,9 @@ Revision history for Perl extension Sereal-Encoder
 *          of the decoder before upgrading to version 2 of the
 *          encoder!
 
+2.04 Wed Mar  5 18:15 2014 (AMS time)
+  - Fix rt.cpan.org #93484 - fencepost error in Encoder.xs (Zefram)
+
 2.03 Tue Jan  7 20:00 2014 (AMS time)
   - (Hopefully) final fixes to FREEZE/THAW functionality:
     => Add safe assertion to make sure that we don't segfault on invalid
index a3661999952cef6fc9fd3b26811676a7bc8a64a0..bb3b32f87c732da446d6eb95cf1d7d316ff7a7eb 100644 (file)
@@ -42,7 +42,7 @@ encode(enc, src, ...)
     SV *hdr_user_data_src = NULL;
   PPCODE:
     assert(enc != NULL);
-    if (items >= 2 && SvOK(ST(2)))
+    if (items > 2 && SvOK(ST(2)))
       hdr_user_data_src = ST(2);
     srl_dump_data_structure(aTHX_ enc, src, hdr_user_data_src);
     assert(enc->buf.pos > enc->buf.start);
index 7f6d2d30ee1a8de8664ab3d4fa2b85a4ad9a1250..52a221ddc00d641ea6571a9c2361d4432dc59e6d 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -36,8 +36,6 @@ t/003_ptable.t
 t/010_desperate.t
 t/020_sort_keys.t
 t/021_sort_keys_option.t
-t/100_roundtrip.t
-t/101_roundtrip_v1.t
 t/110_nobless.t
 t/120_hdr_data.t
 t/130_freezethaw.t
@@ -45,10 +43,11 @@ t/160_recursion.t
 t/200_bulk.t
 t/300_fail.t
 t/400_evil.t
+t/700_roundtrip.t
+t/701_roundtrip_v1.t
 t/800_threads.t
 t/data/corpus
 t/lib/Sereal/BulkTest.pm
 t/lib/Sereal/TestSet.pm
 typemap
-META.yml                                 Module YAML meta-data (added by MakeMaker)
-META.json                                Module JSON meta-data (added by MakeMaker)
+META.yml                                 Module meta-data (added by MakeMaker)
diff --git a/META.json b/META.json
deleted file mode 100644 (file)
index b5e53f9..0000000
--- a/META.json
+++ /dev/null
@@ -1,59 +0,0 @@
-{
-   "abstract" : "Fast, compact, powerful binary serialization",
-   "author" : [
-      "Steffen Mueller <smueller@cpan.org>, Yves Orton <yves@cpan.org>"
-   ],
-   "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921",
-   "license" : [
-      "perl_5"
-   ],
-   "meta-spec" : {
-      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
-      "version" : "2"
-   },
-   "name" : "Sereal-Encoder",
-   "no_index" : {
-      "directory" : [
-         "t",
-         "inc"
-      ]
-   },
-   "prereqs" : {
-      "build" : {
-         "requires" : {
-            "Data::Dumper" : "0",
-            "ExtUtils::ParseXS" : "2.21",
-            "File::Find" : "0",
-            "File::Path" : "0",
-            "File::Spec" : "0",
-            "Scalar::Util" : "0",
-            "Sereal::Decoder" : "2.03",
-            "Test::LongString" : "0",
-            "Test::More" : "0.88",
-            "Test::Warn" : "0"
-         }
-      },
-      "configure" : {
-         "requires" : {
-            "ExtUtils::MakeMaker" : "0"
-         }
-      },
-      "runtime" : {
-         "requires" : {
-            "XSLoader" : "0",
-            "perl" : "5.008"
-         }
-      }
-   },
-   "release_status" : "stable",
-   "resources" : {
-      "bugtracker" : {
-         "web" : "https://github.com/Sereal/Sereal/issues"
-      },
-      "repository" : {
-         "url" : "git://github.com/Sereal/Sereal.git"
-      }
-   },
-   "version" : "2.03"
-}
index 917c859223115b0147bc8ed107a4dc0e76a565b4..e6386eadd376105a3bc6ec6e8215ad2a945cd9c2 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,35 +1,35 @@
----
-abstract: 'Fast, compact, powerful binary serialization'
+--- #YAML:1.0
+name:               Sereal-Encoder
+version:            2.04
+abstract:           Fast, compact, powerful binary serialization
 author:
-  - 'Steffen Mueller <smueller@cpan.org>, Yves Orton <yves@cpan.org>'
-build_requires:
-  Data::Dumper: 0
-  ExtUtils::ParseXS: 2.21
-  File::Find: 0
-  File::Path: 0
-  File::Spec: 0
-  Scalar::Util: 0
-  Sereal::Decoder: 2.03
-  Test::LongString: 0
-  Test::More: 0.88
-  Test::Warn: 0
+    - Steffen Mueller <smueller@cpan.org>, Yves Orton <yves@cpan.org>
+license:            perl
+distribution_type:  module
 configure_requires:
-  ExtUtils::MakeMaker: 0
-dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921'
-license: perl
-meta-spec:
-  url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
-name: Sereal-Encoder
-no_index:
-  directory:
-    - t
-    - inc
+    ExtUtils::MakeMaker:  0
+build_requires:
+    Data::Dumper:       0
+    ExtUtils::ParseXS:  2.21
+    File::Find:         0
+    File::Path:         0
+    File::Spec:         0
+    Scalar::Util:       0
+    Sereal::Decoder:    2.03
+    Test::LongString:   0
+    Test::More:         0.88
+    Test::Warn:         0
 requires:
-  XSLoader: 0
-  perl: 5.008
+    perl:      5.008
+    XSLoader:  0
 resources:
-  bugtracker: https://github.com/Sereal/Sereal/issues
-  repository: git://github.com/Sereal/Sereal.git
-version: 2.03
+    bugtracker:  https://github.com/Sereal/Sereal/issues
+    repository:  git://github.com/Sereal/Sereal.git
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.57_05
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4
index 0c0f9355af299f0ff31043af68d354edd41debad..143051ca18bc5789f51e9ba3dbcf0ffa76970eb1 100644 (file)
@@ -239,7 +239,7 @@ sub parse_hv {
   while ($len--) {
     my $t = substr($data, 0, 1);
     my $o = ord($t);
-    print( "               ", $ind, ($flipflop++ % 2 == 1 ? "VALUE" : "KEY"), ":\n" );
+    printf  "$fmt2%s:\n",("") x $lead_items, $ind, ($flipflop++ %2 == 1 ? "VALUE" : "KEY");
     parse_sv($ind."  ");
   }
 }
index a6365416494b836e7eb7fc9e79a5ac6af3615b52..906007ab861cd608798b2aeac31de3fea693ba4b 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 use Carp qw/croak/;
 use XSLoader;
 
-our $VERSION = '2.03'; # Don't forget to update the TestCompat set for testing against installed decoders!
+our $VERSION = '2.04'; # Don't forget to update the TestCompat set for testing against installed decoders!
 
 # not for public consumption, just for testing.
 (my $num_version = $VERSION) =~ s/_//;
@@ -58,6 +58,8 @@ there is a discussion of the design objectives in
 L<https://github.com/Sereal/Sereal/blob/master/README.pod>, and the output
 of our benchmarks can be seen at
 L<https://github.com/Sereal/Sereal/wiki/Sereal-Comparison-Graphs>.
+For more information on getting the best performance out of Sereal, have a look
+at the L</"PERFORMANCE"> section below.
 
 =head1 CLASS METHODS
 
@@ -205,7 +207,7 @@ various caveats involved.
 
 =head3 no_shared_hashkeys
 
-When the C<no_shared_hashkeys> option is set ot a true value, then
+When the C<no_shared_hashkeys> option is set to a true value, then
 the encoder will disable the detection and elimination of repeated hash
 keys. This only has an effect for serializing structures containing hashes.
 By skipping the detection of repeated hash keys, performance goes up a bit,
@@ -217,7 +219,7 @@ Do not disable this unless you have a reason to.
 
 If this is option is enabled/true then Sereal will use a hash to encode duplicates
 of strings during serialization efficiently using (internal) backreferences. This
-has a peformance and memory penalty during encoding so it defaults to off.
+has a performance and memory penalty during encoding so it defaults to off.
 On the other hand, data structures with many duplicated strings will see a
 significant reduction in the size of the encoded form. Currently only strings
 longer than 3 characters will be deduped, however this may change in the future.
@@ -245,7 +247,7 @@ This option enables a mode of operation that is similar to I<dedupe_strings>
 and if both options are set, I<aliased_dedupe_strings> takes precedence.
 
 The behaviour of I<aliased_dedupe_strings> differs from I<dedupe_strings>
-in that the duplicate occurrances of strings are emitted as Perl language
+in that the duplicate occurrences of strings are emitted as Perl language
 level B<aliases> instead of as Sereal-internal backreferences. This means
 that using this option actually produces a different output data structure
 when decoding. The upshot is that with this option, the application
@@ -277,13 +279,24 @@ The functional interface that is equivalent to using C<new> and C<encode>.
 Expects a data structure to serialize as first argument, optionally followed
 by a hash reference of options (see documentation for C<new()>).
 
-The functional interface is marginally slower than the OO interface since
+The functional interface is quite a bit slower than the OO interface since
 it cannot reuse the encoder object.
 
 =head1 PERFORMANCE
 
+If you care about performance at all, then use the object-oriented interface
+instead of the functional interface. It's a significant difference in performance
+if you are serializing small data structures.
+
 The exact performance in time and space depends heavily on the data structure
-to be serialized. For ready-made comparison scripts, see the
+to be serialized. Often there is a trade-off between space and time. If in doubt,
+do your own testing and most importantly ALWAYS TEST WITH REAL DATA. If you
+care purely about speed at the expense of output size, you can use the
+C<no_shared_hashkeys> option for a small speed-up. If you need smaller output at
+the cost of higher CPU load and more memory used during encoding/decoding,
+try the C<dedupe_strings> option and enable Snappy compression.
+
+For ready-made comparison scripts, see the
 F<author_tools/bench.pl> and F<author_tools/dbench.pl> programs that are part
 of this distribution. Suffice to say that this library is easily competitive
 in both time and space efficiency with the best alternatives.
@@ -304,7 +317,7 @@ by including the original object). But C<FREEZE> can't return a list as with CBO
 This should not be any practical limitation whatsoever. Just return an array
 reference instead of a list.
 
-Here is a contrived example of a class implementing the C<FREEZE> / C<THAW> mechansim.
+Here is a contrived example of a class implementing the C<FREEZE> / C<THAW> mechanism.
 
   package
     File;
@@ -413,10 +426,10 @@ applies to HASH vs. HASHREF.
 Similar to how Sereal can represent arrays and hashes in a full and a compact
 form. For small integers (between -16 and +15 inclusive), Sereal emits only
 one byte including the encoding of the type of data. For larger integers,
-it can use either varints (positive only) or zigzag encoding, which can also
+it can use either variants (positive only) or zigzag encoding, which can also
 represent negative numbers. For a canonical mode, the space optimizations
 would have to be turned off and it would have to be explicitly specified
-whether varint or zigzag encoding is to be used for encoding positive
+whether variant or zigzag encoding is to be used for encoding positive
 integers.
 
 Perl may choose to retain multiple representations of a scalar. Specifically,
@@ -462,7 +475,7 @@ L<https://groups.google.com/forum/?fromgroups#!forum/sereal-announce>
 Sereal development list:
 L<https://groups.google.com/forum/?fromgroups#!forum/sereal-dev>
 
-=head1 AUTHORS
+=head1 AUTHORS AND CONTRIBUTORS
 
 Yves Orton E<lt>demerphq@gmail.comE<gt>
 
@@ -478,6 +491,8 @@ Tim Bunce
 
 Daniel Dragan E<lt>bulkdd@cpan.orgE<gt> (Windows support and bugfixes)
 
+Zefram
+
 Some inspiration and code was taken from Marc Lehmann's
 excellent L<JSON::XS> module due to obvious overlap in
 problem domain. Thank you!
diff --git a/t/100_roundtrip.t b/t/100_roundtrip.t
deleted file mode 100644 (file)
index 2889ce9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!perl
-use strict;
-use warnings;
-use Sereal::Encoder;
-use Data::Dumper;
-use File::Spec;
-
-# These tests use an installed Decoder (or respectively Encoder) to do
-# round-trip testing. There are two strategies, both with drawbacks:
-# - Test::More's is_deeply is waaaay too lenient to catch all the
-#   subtleties that Sereal is supposed to encode.
-# - Serialize - Deserialize - Serialize, then do a string compare.
-#   This won't catch if the first serialization has bogus output
-#   but the subsequent de- & serialization work for the already
-#   bogus output.
-# These tests can't replace carefully crafted manual tests, I fear.
-
-use lib File::Spec->catdir(qw(t lib));
-BEGIN {
-  lib->import('lib')
-    if !-d 't';
-}
-
-use Sereal::TestSet qw(:all);
-use Test::More;
-
-my $ok = have_encoder_and_decoder();
-if (not $ok) {
-  plan skip_all => 'Did not find right version of decoder';
-}
-else {
-  run_roundtrip_tests(2); # 2 is "run for proto version 2 only"
-}
-
-
-pass();
-done_testing();
-
diff --git a/t/101_roundtrip_v1.t b/t/101_roundtrip_v1.t
deleted file mode 100644 (file)
index 3c065f1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!perl
-use strict;
-use warnings;
-use Sereal::Encoder;
-use Data::Dumper;
-use File::Spec;
-
-# These tests use an installed Decoder (or respectively Encoder) to do
-# round-trip testing. There are two strategies, both with drawbacks:
-# - Test::More's is_deeply is waaaay too lenient to catch all the
-#   subtleties that Sereal is supposed to encode.
-# - Serialize - Deserialize - Serialize, then do a string compare.
-#   This won't catch if the first serialization has bogus output
-#   but the subsequent de- & serialization work for the already
-#   bogus output.
-# These tests can't replace carefully crafted manual tests, I fear.
-
-use lib File::Spec->catdir(qw(t lib));
-BEGIN {
-  lib->import('lib')
-    if !-d 't';
-}
-
-use Sereal::TestSet qw(:all);
-use Test::More;
-
-my $ok = have_encoder_and_decoder();
-if (not $ok) {
-  plan skip_all => 'Did not find right version of decoder';
-}
-else {
-  run_roundtrip_tests(1); # 1 is "run for proto-version 1 only"
-}
-
-
-pass();
-done_testing();
-
diff --git a/t/700_roundtrip.t b/t/700_roundtrip.t
new file mode 100644 (file)
index 0000000..2889ce9
--- /dev/null
@@ -0,0 +1,38 @@
+#!perl
+use strict;
+use warnings;
+use Sereal::Encoder;
+use Data::Dumper;
+use File::Spec;
+
+# These tests use an installed Decoder (or respectively Encoder) to do
+# round-trip testing. There are two strategies, both with drawbacks:
+# - Test::More's is_deeply is waaaay too lenient to catch all the
+#   subtleties that Sereal is supposed to encode.
+# - Serialize - Deserialize - Serialize, then do a string compare.
+#   This won't catch if the first serialization has bogus output
+#   but the subsequent de- & serialization work for the already
+#   bogus output.
+# These tests can't replace carefully crafted manual tests, I fear.
+
+use lib File::Spec->catdir(qw(t lib));
+BEGIN {
+  lib->import('lib')
+    if !-d 't';
+}
+
+use Sereal::TestSet qw(:all);
+use Test::More;
+
+my $ok = have_encoder_and_decoder();
+if (not $ok) {
+  plan skip_all => 'Did not find right version of decoder';
+}
+else {
+  run_roundtrip_tests(2); # 2 is "run for proto version 2 only"
+}
+
+
+pass();
+done_testing();
+
diff --git a/t/701_roundtrip_v1.t b/t/701_roundtrip_v1.t
new file mode 100644 (file)
index 0000000..3c065f1
--- /dev/null
@@ -0,0 +1,38 @@
+#!perl
+use strict;
+use warnings;
+use Sereal::Encoder;
+use Data::Dumper;
+use File::Spec;
+
+# These tests use an installed Decoder (or respectively Encoder) to do
+# round-trip testing. There are two strategies, both with drawbacks:
+# - Test::More's is_deeply is waaaay too lenient to catch all the
+#   subtleties that Sereal is supposed to encode.
+# - Serialize - Deserialize - Serialize, then do a string compare.
+#   This won't catch if the first serialization has bogus output
+#   but the subsequent de- & serialization work for the already
+#   bogus output.
+# These tests can't replace carefully crafted manual tests, I fear.
+
+use lib File::Spec->catdir(qw(t lib));
+BEGIN {
+  lib->import('lib')
+    if !-d 't';
+}
+
+use Sereal::TestSet qw(:all);
+use Test::More;
+
+my $ok = have_encoder_and_decoder();
+if (not $ok) {
+  plan skip_all => 'Did not find right version of decoder';
+}
+else {
+  run_roundtrip_tests(1); # 1 is "run for proto-version 1 only"
+}
+
+
+pass();
+done_testing();
+