AnnotationParser optimization - JEP-149 (original) (raw)
Peter Levart peter.levart at gmail.com
Tue Nov 27 07:52:50 UTC 2012
- Previous message: Request for Review : CR#8004015 : Add interface extends and defaults for basic functional interfaces
- Next message: RFR (S): 7155168: java/util/TimeZone/Bug6912560.java: expected Asia/Tokyo
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi all,
This might not be much of an improvement, but it is very easy to do:
--- a/src/share/classes/sun/reflect/annotation/AnnotationParser.java Thu Nov 15 15:40:03 2012 -0800 +++ b/src/share/classes/sun/reflect/annotation/AnnotationParser.java Tue Nov 27 08:39:58 2012 +0100 @@ -227,7 +227,7 @@
Map<String, Class<?>> memberTypes = type.memberTypes();
Map<String, Object> memberValues =
new LinkedHashMap<String, Object>(type.memberDefaults());
new HashMap<String, Object>(type.memberDefaults()); int numMembers = buf.getShort() & 0xFFFF; for (int i = 0; i < numMembers; i++) {
It saves 1 OOP and 1 boolean for each Annotation instance + 2 OOPs for each Annotation member value.
It changes the serialization format of Annotation instances, but in a way that is backwards and forwards compatible.
Semantically it does not present any difference, since the only place that the Map is used is to Map.get(member) in the AnnotationInvocationHandler - it is never iterated.
Regards, Peter
- Previous message: Request for Review : CR#8004015 : Add interface extends and defaults for basic functional interfaces
- Next message: RFR (S): 7155168: java/util/TimeZone/Bug6912560.java: expected Asia/Tokyo
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]