Given an object o
, and a member named s
, where s
is a string, we can use reflection to get the field of o
named the contents of s
.
As part of this process, presumably we need to look up some table of metadata for the class, to work out both whether the field exists and where it is relative to the base of objects of that class.
But after that, assuming all objects of the same class have the same layout, we shouldn't have to use reflection again. We've now got the offset of the field from the base, we could just do a pointer addition an be in the right spot for any other object of that class.
So is there anyway to "save" the results of a reflection lookup, so they can be reused on different objects of the same type?
Aucun commentaire:
Enregistrer un commentaire