From c855ba64b4efabcd6248791962c73a3806b85bda Mon Sep 17 00:00:00 2001 From: cleem Date: Fri, 30 Jan 2015 13:10:03 +0300 Subject: [PATCH] Pack empty arrays as zero-length arrays --- example/simple.d | 4 +++- src/msgpack.d | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/example/simple.d b/example/simple.d index 032ae92..86aa445 100644 --- a/example/simple.d +++ b/example/simple.d @@ -14,7 +14,9 @@ void main() { auto packer = packer(appender!(ubyte[])()); - packer.packArray(null, true, "Hi!", -1, [1, 2]); + int[] emptyArray; + int[int] emptyMap; + packer.packArray(null, true, "Hi!", -1, [1, 2], emptyArray, emptyMap); auto unpacker = StreamingUnpacker(packer.stream.data); diff --git a/src/msgpack.d b/src/msgpack.d index 71cbfc3..8870dc2 100644 --- a/src/msgpack.d +++ b/src/msgpack.d @@ -698,9 +698,6 @@ struct PackerImpl(Stream) if (isOutputRange!(Stream, ubyte) && isOutputRange!(St } } - if (array.empty) - return packNil(); - // Raw bytes static if (isByte!(U) || isSomeChar!(U)) { ubyte[] raw = cast(ubyte[])array; @@ -720,9 +717,6 @@ struct PackerImpl(Stream) if (isOutputRange!(Stream, ubyte) && isOutputRange!(St /// ditto ref PackerImpl pack(T)(in T array) if (isAssociativeArray!T) { - if (array is null) - return packNil(); - beginMap(array.length); foreach (key, value; array) { pack(key);