mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Great refactoring
This commit is contained in:
+6
-2
@@ -119,7 +119,11 @@ public abstract class ByteableMarshaller<E extends Byteable>
|
||||
public void write(Bytes bytes, E e) {
|
||||
Bytes eBytes = e.bytes();
|
||||
if (eBytes != null) {
|
||||
bytes.write(eBytes, e.offset(), size);
|
||||
if (eBytes != bytes || bytes.position() != e.offset()) {
|
||||
bytes.write(eBytes, e.offset(), size);
|
||||
} else {
|
||||
bytes.skip(size);
|
||||
}
|
||||
} else {
|
||||
throw new NullPointerException("You are trying to write a byteable object of " +
|
||||
e.getClass() + ", " +
|
||||
@@ -142,7 +146,7 @@ public abstract class ByteableMarshaller<E extends Byteable>
|
||||
try {
|
||||
if (toReuse == null)
|
||||
toReuse = getInstance();
|
||||
setBytesAndOffset(toReuse, bytes);
|
||||
toReuse.bytes(bytes, bytes.position());
|
||||
bytes.skip(size);
|
||||
return toReuse;
|
||||
} catch (Exception ex) {
|
||||
|
||||
+1
-2
@@ -492,8 +492,7 @@ public final class DataValueBytesMarshallers {
|
||||
sb.append(" if (toReuse == null)\n");
|
||||
sb.append(" toReuse = getInstance();\n");
|
||||
sb.append(" if (toReuse instanceof Byteable) {\n");
|
||||
sb.append(" " +
|
||||
"ByteableMarshaller.setBytesAndOffset(((Byteable) toReuse), bytes);\n");
|
||||
sb.append(" ((Byteable) toReuse).bytes(bytes, bytes.position());\n");
|
||||
sb.append(" bytes.skip(size);\n");
|
||||
sb.append(" return toReuse;\n");
|
||||
sb.append(" }\n");
|
||||
|
||||
+2
-1
@@ -16,8 +16,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.openhft.chronicle.hash.serialization;
|
||||
package net.openhft.chronicle.hash.serialization.internal;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
|
||||
import static net.openhft.lang.io.IOTools.stopBitLength;
|
||||
Reference in New Issue
Block a user