vgritsenko 02/04/19 12:06:54 Modified: src/java/org/apache/cocoon/caching ComponentCacheKey.java PipelineCacheKey.java Log: Optimize cache keys Revision Changes Path 1.6 +9 -12 xml-cocoon2/src/java/org/apache/cocoon/caching/ComponentCacheKey.java Index: ComponentCacheKey.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/ComponentCacheKey.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ComponentCacheKey.java 22 Feb 2002 07:03:49 -0000 1.5 +++ ComponentCacheKey.java 19 Apr 2002 19:06:54 -0000 1.6 @@ -59,7 +59,7 @@ * is unique inside the component space. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: ComponentCacheKey.java,v 1.5 2002/02/22 07:03:49 cziegeler Exp $ + * @version CVS $Id: ComponentCacheKey.java,v 1.6 2002/04/19 19:06:54 vgritsenko Exp $ */ public final class ComponentCacheKey implements java.io.Serializable { @@ -68,30 +68,27 @@ public static final int ComponentType_Serializer = 3; public static final int ComponentType_Reader = 4; - private String toStringValue; + private String key; public ComponentCacheKey(int componentType, String componentIdentifier, long cacheKey) { // generate the toString value - StringBuffer buffer = new StringBuffer("CCK:"); - buffer.append(componentType) - .append('-') - .append(componentIdentifier) - .append('-') - .append(cacheKey); - this.toStringValue = buffer.toString(); + this.key = "CCK:" + + componentType + '-' + + componentIdentifier + '-' + + cacheKey; } public String toString() { - return this.toStringValue; + return this.key; } public boolean equals(Object object) { - return this.toStringValue.equals(object.toString()); + return this.key.equals(object.toString()); } public int hashCode() { - return this.toStringValue.hashCode(); + return this.key.hashCode(); } } 1.6 +17 -15 xml-cocoon2/src/java/org/apache/cocoon/caching/PipelineCacheKey.java Index: PipelineCacheKey.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/PipelineCacheKey.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- PipelineCacheKey.java 22 Feb 2002 07:03:49 -0000 1.5 +++ PipelineCacheKey.java 19 Apr 2002 19:06:54 -0000 1.6 @@ -58,39 +58,41 @@ * or more <code>ComponentCacheKey</code> objects. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: PipelineCacheKey.java,v 1.5 2002/02/22 07:03:49 cziegeler Exp $ + * @version CVS $Id: PipelineCacheKey.java,v 1.6 2002/04/19 19:06:54 vgritsenko Exp $ */ public final class PipelineCacheKey { - private List list; - private String toStringValue = "PCK:"; + private StringBuffer value; + private String toStringValue; public void addKey(ComponentCacheKey key) { - if (this.list == null) { - this.list = new ArrayList(); + if (this.value == null) { + this.value = new StringBuffer("PCK:"); } - this.list.add(key); - toStringValue += key.toString(); + this.value.append(key.toString()); + toStringValue = null; } public void addKey(PipelineCacheKey key) { - if (this.list == null) { - this.list = new ArrayList(); + if (this.value == null) { + this.value = new StringBuffer("PCK:"); } - this.list.add(key); - toStringValue += key.toString(); + this.value.append(key.toString()); + toStringValue = null; } public String toString() { - return toStringValue; + if (value == null) { + return "PCK:"; + } + return (toStringValue = value.toString()); } public boolean equals(Object object) { - return this.toStringValue.equals(object.toString()); + return this.toString().equals(object.toString()); } public int hashCode() { - return this.toStringValue.hashCode(); + return this.toString().hashCode(); } - }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]