trace("kryo", "Class " + serializer.getType().getName()
+ ". Found a set of consecutive primitive fields. Number of fields = " + primitiveLength
+ ". Byte length = " + (endPrimitives - startPrimitives) + " Start offset = " + startPrimitives
+ " endOffset=" + endPrimitives);
// TODO: register a region instead of a field
CachedField cf = new UnsafeRegionField(startPrimitives, (endPrimitives - startPrimitives));
cf.field = lastField;
cachedFields.add(cf);
} else {
if (lastField != null)
cachedFields.add(serializer.newCachedField(lastField, cachedFields.size(), lastAccessIndex));
}
cachedFields.add(serializer.newCachedField(field, cachedFields.size(), accessIndex));
} else if (!field.getType().isPrimitive()) {
cachedFields.add(serializer.newCachedField(field, cachedFields.size(), accessIndex));
} else if (!lastWasPrimitive) {
// If previous field was non primitive, it marks a start
// of a region of primitive fields
startPrimitives = fieldOffset;
lastWasPrimitive = true;
primitiveLength = 1;
} else {
primitiveLength++;
}
lastAccessIndex = accessIndex;
lastField = field;
lastFieldEndOffset = fieldEndOffset;
}
if (!serializer.getUseAsmEnabled() && serializer.getUseMemRegions() && lastWasPrimitive) {
endPrimitives = lastFieldEndOffset;
if (primitiveLength > 1) {
if (TRACE) {
trace("kryo", "Class " + serializer.getType().getName()
+ ". Found a set of consecutive primitive fields. Number of fields = " + primitiveLength + ". Byte length = "
+ (endPrimitives - startPrimitives) + " Start offset = " + startPrimitives + " endOffset=" + endPrimitives);
}
// register a region instead of a field
CachedField cf = new UnsafeRegionField(startPrimitives, (endPrimitives - startPrimitives));
cf.field = lastField;
cachedFields.add(cf);
} else {
if (lastField != null) cachedFields.add(serializer.newCachedField(lastField, cachedFields.size(), lastAccessIndex));
}