aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-11-04 06:00:46 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-11-04 06:00:46 +0000
commiteb12cc5d6bcbc25ea70f678321693971a0bd921c (patch)
tree90e5273bd644f5509cb4253f5c1dfe99aba13510 /src/main
parentbfdfdff690cdf56edb25ef28740da13dc2c86785 (diff)
downloadjavassist-eb12cc5d6bcbc25ea70f678321693971a0bd921c.tar.gz
javassist-eb12cc5d6bcbc25ea70f678321693971a0bd921c.zip
updated CtMember.append() for better performance.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@216 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main')
-rw-r--r--src/main/javassist/CtClassType.java34
-rw-r--r--src/main/javassist/CtMember.java10
2 files changed, 35 insertions, 9 deletions
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java
index bdf389cd..8d8e67d1 100644
--- a/src/main/javassist/CtClassType.java
+++ b/src/main/javassist/CtClassType.java
@@ -618,11 +618,16 @@ class CtClassType extends CtClass {
if (fieldsCache == null) {
List list = getClassFile2().getFields();
int n = list.size();
+ CtMember allFields = null;
+ CtField tail = null;
for (int i = 0; i < n; ++i) {
FieldInfo finfo = (FieldInfo)list.get(i);
- fieldsCache = CtMember.append(fieldsCache,
- new CtField(finfo, this));
+ CtField newTail = new CtField(finfo, this);
+ allFields = CtMember.append(allFields, tail, newTail);
+ tail = newTail;
}
+
+ fieldsCache = allFields;
}
return fieldsCache;
@@ -721,13 +726,18 @@ class CtClassType extends CtClass {
if (constructorsCache == null) {
List list = getClassFile2().getMethods();
int n = list.size();
+ CtMember allConstructors = null;
+ CtConstructor tail = null;
for (int i = 0; i < n; ++i) {
MethodInfo minfo = (MethodInfo)list.get(i);
- if (minfo.isConstructor())
- constructorsCache
- = CtMember.append(constructorsCache,
- new CtConstructor(minfo, this));
+ if (minfo.isConstructor()) {
+ CtConstructor newTail = new CtConstructor(minfo, this);
+ allConstructors = CtMember.append(allConstructors, tail, newTail);
+ tail = newTail;
+ }
}
+
+ constructorsCache = allConstructors;
}
return constructorsCache;
@@ -870,12 +880,18 @@ class CtClassType extends CtClass {
if (methodsCache == null) {
List list = getClassFile2().getMethods();
int n = list.size();
+ CtMember allMethods = null;
+ CtMethod tail = null;
for (int i = 0; i < n; ++i) {
MethodInfo minfo = (MethodInfo)list.get(i);
- if (minfo.isMethod())
- methodsCache = CtMember.append(methodsCache,
- new CtMethod(minfo, this));
+ if (minfo.isMethod()) {
+ CtMethod newTail = new CtMethod(minfo, this);
+ allMethods = CtMember.append(allMethods, tail, newTail);
+ tail = newTail;
+ }
}
+
+ methodsCache = allMethods;
}
return methodsCache;
diff --git a/src/main/javassist/CtMember.java b/src/main/javassist/CtMember.java
index d6bd14f1..b04e107a 100644
--- a/src/main/javassist/CtMember.java
+++ b/src/main/javassist/CtMember.java
@@ -25,6 +25,16 @@ public abstract class CtMember {
protected CtMember(CtClass clazz) { declaringClass = clazz; }
+ static CtMember append(CtMember list, CtMember previousTail, CtMember tail) {
+ tail.next = null;
+ if (list == null)
+ return tail;
+ else {
+ previousTail.next = tail;
+ return list;
+ }
+ }
+
static CtMember append(CtMember list, CtMember tail) {
tail.next = null;
if (list == null)