You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2005/02/13 15:50:36 UTC
cvs commit: xml-security/src/org/apache/xml/security/utils CachedXPathAPIHolder.java
raul 2005/02/13 06:50:36
Modified: src/org/apache/xml/security/utils CachedXPathAPIHolder.java
Log:
Only create CachedXPathAPI when needed.
Revision Changes Path
1.7 +14 -17 xml-security/src/org/apache/xml/security/utils/CachedXPathAPIHolder.java
Index: CachedXPathAPIHolder.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/CachedXPathAPIHolder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CachedXPathAPIHolder.java 13 Feb 2005 12:05:18 -0000 1.6
+++ CachedXPathAPIHolder.java 13 Feb 2005 14:50:36 -0000 1.7
@@ -27,28 +27,25 @@
static ThreadLocal local=new ThreadLocal();
static ThreadLocal localDoc=new ThreadLocal();
- public static void setDoc(Document doc) {
- CachedXPathAPI cx=(CachedXPathAPI)local.get();
- if (cx==null) {
- cx=new CachedXPathAPI();
- local.set(cx);
- localDoc.set(doc);
- } else {
- if (localDoc.get()!=doc) {
- //Different docs reset.
- cx.getXPathContext().reset();
- localDoc.set(doc);
- }
-
+ public static void setDoc(Document doc) {
+ if (localDoc.get()!=doc) {
+ CachedXPathAPI cx=(CachedXPathAPI)local.get();
+ if (cx==null) {
+ cx=new CachedXPathAPI();
+ local.set(cx);
+ localDoc.set(doc);
+ return;
+ }
+ //Different docs reset.
+ cx.getXPathContext().reset();
+ localDoc.set(doc);
}
}
/**
* @return
*/
- public static CachedXPathAPI getCachedXPathAPI() {
-
- CachedXPathAPI cx=(CachedXPathAPI)local.get();
- cx=(CachedXPathAPI)local.get();
+ public static CachedXPathAPI getCachedXPathAPI() {
+ CachedXPathAPI cx=(CachedXPathAPI)local.get();
if (cx==null) {
cx=new CachedXPathAPI();
local.set(cx);