[#1634] Improve the performance of Factory.newRecord() by avoiding

accessing record values by Field rather than by index
This commit is contained in:
Lukas Eder 2012-07-27 14:00:43 +02:00
parent e2b6b8dc9a
commit 79c29febc0

View File

@ -95,8 +95,9 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
public final List<Attachable> getAttachables() {
List<Attachable> result = new ArrayList<Attachable>();
for (Field<?> field : getFields()) {
Object value = getValue(field);
int size = getFields().size();
for (int i = 0; i < size; i++) {
Object value = getValue0(i);
if (value instanceof Attachable) {
result.add((Attachable) value);
@ -131,6 +132,11 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
return getFields().size();
}
@SuppressWarnings("unchecked")
final <T> Value<T> getValue0(int index) {
return (Value<T>) getValues()[index];
}
@SuppressWarnings("unchecked")
final <T> Value<T> getValue0(Field<T> field) {
return (Value<T>) getValues()[getIndex(field)];