[jboss-cvs] JBossAS SVN: r59821 - branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 19 07:58:50 EST 2007
Author: kabir.khan at jboss.com
Date: 2007-01-19 07:58:50 -0500 (Fri, 19 Jan 2007)
New Revision: 59821
Modified:
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java
Log:
Minor optimization, no need to first iterate over fields when classifying them and then while weaving
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java 2007-01-19 12:58:21 UTC (rev 59820)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java 2007-01-19 12:58:50 UTC (rev 59821)
@@ -78,27 +78,28 @@
List fields = Instrumentor.getAdvisableFields(clazz);
int fieldIndex = fieldOffset(clazz.getSuperclass());
- JoinpointClassification[] classificationGet = classifyFieldGet(clazz, advisor);
- JoinpointClassification[] classificationSet = classifyFieldSet(clazz, advisor);
- Iterator it = fields.iterator();
boolean skipFieldInterception = true;
- for (int index = 0; it.hasNext(); index++, fieldIndex++)
+ if (fields.size() > 0)
{
- CtField field = (CtField) it.next();
-
- if (!isPrepared(classificationGet[index]) && !isPrepared(classificationSet[index]))
+ Iterator it = fields.iterator();
+ for (int index = 0; it.hasNext(); index++, fieldIndex++)
{
- continue;
+ CtField field = (CtField) it.next();
+ JoinpointClassification classificationGet = instrumentor.joinpointClassifier.classifyFieldGet(field, advisor);
+ JoinpointClassification classificationSet = instrumentor.joinpointClassifier.classifyFieldSet(field, advisor);
+ if (!isPrepared(classificationGet) && !isPrepared(classificationSet))
+ {
+ continue;
+ }
+
+ if (!javassist.Modifier.isPrivate(field.getModifiers()))
+ {
+ skipFieldInterception = false;
+ }
+
+ doBuildFieldWrappers(clazz, field, fieldIndex, classificationGet, classificationSet);
}
-
- if (!javassist.Modifier.isPrivate(field.getModifiers()))
- {
- skipFieldInterception = false;
- }
-
- doBuildFieldWrappers(clazz, field, fieldIndex, classificationGet[index], classificationSet[index]);
- }
-
+ }
if (skipFieldInterception)
{
advisor.getManager().skipFieldAccess(clazz.getName());
@@ -107,7 +108,6 @@
{
advisor.getManager().addFieldInterceptionMarker(clazz.getName());
}
-
}
protected boolean isPrepared(JoinpointClassification classification)
@@ -136,7 +136,7 @@
if (!Modifier.isPrivate(field.getModifiers()) && Instrumentor.isAdvisable(field))
{
JoinpointClassification fieldGetClassification = classifier.classifyFieldGet(field, fieldsAdvisor);
-
+
if (fieldGetClassification.equals(JoinpointClassification.WRAPPED))
{
converted = true;
@@ -306,44 +306,6 @@
return offset;
}
- /**
- * Classifies the field read joinpoints.
- * @param clazz the clazz whose field reads will be classified.
- * @param advisor the advisor associated to <code>clazz</code>.
- * @return a classification array.
- */
- private JoinpointClassification[] classifyFieldGet(CtClass clazz, ClassAdvisor advisor) throws NotFoundException
- {
- List fields = instrumentor.getAdvisableFields(clazz);
- JoinpointClassification[] classification = new JoinpointClassification[fields.size()];
- int index = 0;
- for (Iterator iterator = fields.iterator(); iterator.hasNext(); index++)
- {
- CtField field = (CtField) iterator.next();
- classification[index] = instrumentor.joinpointClassifier.classifyFieldGet(field, advisor);
- }
- return classification;
- }
-
- /**
- * Classifies the field write joinpoints.
- * @param clazz the clazz whose field writes will be classified.
- * @param advisor the advisor associated to <code>clazz</code>.
- * @return a classification array.
- */
- private JoinpointClassification[] classifyFieldSet(CtClass clazz, ClassAdvisor advisor) throws NotFoundException
- {
- List fields = instrumentor.getAdvisableFields(clazz);
- JoinpointClassification[] classification = new JoinpointClassification[fields.size()];
- int index = 0;
- for (Iterator iterator = fields.iterator(); iterator.hasNext(); index++)
- {
- CtField field = (CtField) iterator.next();
- classification[index] = instrumentor.joinpointClassifier.classifyFieldSet(field, advisor);
- }
- return classification;
- }
-
protected String addFieldReadInfoFieldWithAccessors(int modifiers, CtClass addTo, CtField field) throws NotFoundException, CannotCompileException
{
return addFieldReadInfoFieldWithAccessors(modifiers, addTo, field, null);
More information about the jboss-cvs-commits
mailing list