-
Notifications
You must be signed in to change notification settings - Fork 886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not use arrays in InstrumentationModule #3057
Do not use arrays in InstrumentationModule #3057
Conversation
31ea56b
to
09d9a9b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
return new GenerateMuzzleMethodsAndFields( | ||
classVisitor, | ||
implementationContext.getClassFileVersion().isAtLeast(ClassFileVersion.JAVA_V6)); | ||
return new GenerateMuzzleMethodsAndFields(classVisitor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -47,7 +46,6 @@ | |||
class MuzzleCodeGenerator implements AsmVisitorWrapper { | |||
private static final Logger log = LoggerFactory.getLogger(MuzzleCodeGenerator.class); | |||
|
|||
private static final String MUZZLE_REFERENCES_FIELD_NAME = "muzzleReferences"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
mv.visitTypeInsn(Opcodes.NEW, "java/util/HashMap"); | ||
// stack: map | ||
mv.visitInsn(Opcodes.DUP); | ||
// stack: map, map | ||
mv.visitLdcInsn(contextStoreClasses.size()); | ||
// stack: map, map, size | ||
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/HashMap", "<init>", "(I)V", false); | ||
writeNewMap(mv, contextStoreClasses.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// stack: map | ||
mv.visitInsn(Opcodes.DUP); | ||
// stack: map, map | ||
// pass bigger size to avoid resizes; same formula as in e.g. HashSet(Collection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
InstrumentationModule
, it now uses lists & maps.muzzleReferences
field:MuzzleMatcher
maintains a reference toReferenceMatcher
, there's no need to keep the reference to the collection of classrefs anymore.MuzzleCodeGenerator
to private methods.