ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.pm
(Generate patch)

Comparing CBOR-XS/XS.pm (file contents):
Revision 1.55 by root, Mon Apr 25 21:30:23 2016 UTC vs.
Revision 1.56 by root, Mon Apr 25 21:44:13 2016 UTC

1019decimal fractions is generally fast. Decoding bigints can be slow for very 1019decimal fractions is generally fast. Decoding bigints can be slow for very
1020big numbers, and decoding bigfloats or arbitrary-exponent bigfloats can be 1020big numbers, and decoding bigfloats or arbitrary-exponent bigfloats can be
1021extremely slow (minutes, decades) for large exponents. 1021extremely slow (minutes, decades) for large exponents.
1022 1022
1023Additionally, L<Math::BigInt> can take advantage of other bignum 1023Additionally, L<Math::BigInt> can take advantage of other bignum
1024libraries, such as L<Math::GMP> or L<Math::Pari>, which cannot handle big 1024libraries, such as L<Math::GMP>, which cannot handle big
1025floats with large exponents, and might simply abort or crash your program, 1025floats with large exponents, and might simply abort or crash your program,
1026due to their code quality. 1026due to their code quality.
1027 1027
1028This can be a concern if you want to parse untrusted CBOR. If it is, you 1028This can be a concern if you want to parse untrusted CBOR. If it is, you
1029need to disable decoding of tag 2 (bigint) and 3 (negative bigint) types, 1029need to disable decoding of tag 2 (bigint) and 3 (negative bigint) types,
1030which will also disable bigfloat support (to be sure, you can also disable 1030which will also disable bigfloat support (to be sure, you can also disable
1031types 5 and 265). 1031types 4, 5, 264 and 265).
1032 1032
1033 1033
1034=head1 CBOR IMPLEMENTATION NOTES 1034=head1 CBOR IMPLEMENTATION NOTES
1035 1035
1036This section contains some random implementation notes. They do not 1036This section contains some random implementation notes. They do not
1110 scalar Time::Piece::gmtime (pop) 1110 scalar Time::Piece::gmtime (pop)
1111 }, 1111 },
1112 1112
1113 2 => sub { # pos bigint 1113 2 => sub { # pos bigint
1114 require Math::BigInt; 1114 require Math::BigInt;
1115 Math::BigInt->new ("0x" . unpack "H*", pop) 1115 Math::BigInt->from_hex ("0x" . unpack "H*", pop)
1116 }, 1116 },
1117 1117
1118 3 => sub { # neg bigint 1118 3 => sub { # neg bigint
1119 require Math::BigInt; 1119 require Math::BigInt;
1120 -Math::BigInt->new ("0x" . unpack "H*", pop) 1120 -Math::BigInt->from_hex ("0x" . unpack "H*", pop)
1121 }, 1121 },
1122 1122
1123 4 => sub { # decimal fraction, array 1123 4 => sub { # decimal fraction, array
1124 require Math::BigFloat; 1124 require Math::BigFloat;
1125 Math::BigFloat->new ($_[1][1] . "E" . $_[1][0]) 1125 Math::BigFloat->new ($_[1][1] . "E" . $_[1][0])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines