-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plumb OutputStream through generators
When an IO is given, we should try to write directly to it. This patch moves that direction by always doing JSON dumping into an OutputStream, which can be implemented on top of a given IO or by producing a ByteList via a ByteArrayOutputStream.
- Loading branch information
Showing
7 changed files
with
156 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package json.ext; | ||
|
||
import org.jcodings.Encoding; | ||
import org.jruby.util.ByteList; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
public class ByteListDirectOutputStream extends ByteArrayOutputStream { | ||
ByteListDirectOutputStream(int size) { | ||
super(size); | ||
} | ||
|
||
public ByteList toByteListDirect(Encoding encoding) { | ||
return new ByteList(buf, 0, count, encoding, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.