Skip to content

Commit

Permalink
serialization improvements: remove TODOs
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Escher <eclipse@erikescher.de>
  • Loading branch information
erikescher committed Jan 20, 2020
1 parent feea7de commit df93718
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 5 deletions.
3 changes: 0 additions & 3 deletions json/src/main/java/org/eclipse/ditto/json/CborFactory.java
Expand Up @@ -58,7 +58,6 @@ public static JsonValue readFrom(final byte[] bytes, int offset, int length) {
}

public static JsonValue readFrom(ByteBuffer byteBuffer) {
// TODO: move / duplicate the bytebuffer array shortcut here?
byteBuffer = byteBuffer.slice(); // ensure that buffers position is zero so that offsets determined by CBORParser map directly to positions in this buffer.
try{
final CBORParser parser = jacksonCborFactory.createParser(ByteBufferInputStream.of(byteBuffer));
Expand Down Expand Up @@ -153,7 +152,6 @@ private static JsonObject parseObject(CBORParser parser, ByteBuffer byteBuffer)
}
final long endOffset = parser.getTokenLocation().getByteOffset();
return ImmutableJsonObject.of(map, getBytesFromInputSource(startOffset, endOffset, byteBuffer));
// TODO: trust that implementations in this package don't use passed maps to avoid copying them in JsonObject?
}

private static JsonArray parseArray(CBORParser parser, ByteBuffer byteBuffer) throws IOException {
Expand All @@ -165,7 +163,6 @@ private static JsonArray parseArray(CBORParser parser, ByteBuffer byteBuffer) th
}
final long endOffset = parser.getTokenLocation().getByteOffset() ;
return ImmutableJsonArray.of(list, getBytesFromInputSource(startOffset, endOffset, byteBuffer));
// TODO: trust that implementations in this package don't use passed lists to avoid copying them in JsonArray?
}

private static byte[] getBytesFromInputSource(final long startOffset, final long endOffset, final ByteBuffer byteBuffer){
Expand Down
Expand Up @@ -54,7 +54,6 @@ protected Result<PolicyEvent> doApply(final Context<PolicyId> context, @Nullable
.collect(JsonCollectors.valuesToArray());

try {
// TODO: this calculates only the size of the entries and ignores the PolicyID and surrounding JSON
PolicyCommandSizeValidator.getInstance().ensureValidSize(
policyEntriesJsonArray::getUpperBoundForStringSize,
() -> policyEntriesJsonArray.toString().length(),
Expand Down
Expand Up @@ -40,7 +40,6 @@ protected void serializeIntoByteBuffer(final JsonObject jsonObject, final ByteBu

@Override
protected JsonValue deserializeFromByteBuffer(ByteBuffer byteBuffer) {
// TODO: potentially use the shortcut to array based stuff directly here?
return CborFactory.readFrom(byteBuffer);
}
}

0 comments on commit df93718

Please sign in to comment.