Descriptor d = ((MessageOrBuilder)r).getDescriptorForType();
FieldDescriptor[] fields = fieldCache.get(d);
if (fields == null) { // cache miss
fields = new FieldDescriptor[s.getFields().size()];
for (Field f : s.getFields())
fields[f.pos()] = d.findFieldByName(f.name());
fieldCache.put(d, fields); // update cache
}
return fields;
}