Great refactoring

This commit is contained in:
leventov
2015-01-17 03:19:35 +07:00
parent 8a4ad9ade2
commit d897891bfb
72 changed files with 5612 additions and 6382 deletions
@@ -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) {
@@ -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");
@@ -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;