Commit Graph

3 Commits

Author SHA1 Message Date
Kyle Huey
601d68ae79 Bug 648997: Implement BlobBuilder spec as MozBlobBuilder. r=sicking.
Note that there is one key difference between this implementation and the spec.  In this patch MozBlobBuilder.getBlob("content/type"); returns a Blob and clears the MozBlobBuilder.  In the spec the BlobBuilder is not cleared.  Thus,

let bb = new MozBlobBuilder();
MozBlobBuilder.append("foo");
let blob1 = MozBlobBuilder.getBlob("content/type");
// blob1 contains "foo"
MozBlobBuilder.append("bar");
let blob2 = MozBlobBuilder.getBlob("content/type");
// blob2 contains "bar", the spec says it should contain "foobar".

IMO, the spec behavior optimizes for the wrong case.  BlobBuilder will probably be used mostly as a one-shot API.  Additionally, the spec requires the BlobBuilder to hang on to potentially large amounts of memory between the getBlob() call and when the BlobBuilder is GCd.

These issues have been raised on the listserv.
2011-05-20 10:18:45 -07:00
Kyle Huey
0018d52058 Backed out changeset b8404a1d3153 2011-05-20 17:00:13 -07:00
Kyle Huey
7da7ee7e4b Bug 648997: Implement BlobBuilder spec as mozBlobBuilder. r=sicking.
Note that there is one key difference between this implementation and the spec.  In this patch mozBlobBuilder.getBlob("content/type"); returns a Blob and clears the mozBlobBuilder.  In the spec the BlobBuilder is not cleared.  Thus,

let bb = new mozBlobBuilder();
mozBlobBuilder.append("foo");
let blob1 = mozBlobBuilder.getBlob("content/type");
// blob1 contains "foo"
mozBlobBuilder.append("bar");
let blob2 = mozBlobBuilder.getBlob("content/type");
// blob2 contains "bar", the spec says it should contain "foobar".

IMO, the spec behavior optimizes for the wrong case.  BlobBuilder will probably be used mostly as a one-shot API.  Additionally, the spec requires the BlobBuilder to hang on to potentially large amounts of memory between the getBlob() call and when the BlobBuilder is GCd.

These issues have been raised on the listserv.
2011-05-20 10:18:45 -07:00