Skip to content

Commit

Permalink
Cache atomized value of NodeProxy
Browse files Browse the repository at this point in the history
Can someone who knows better than me confirm whether this is valid ?

Looks like about 7.90s —> 7.70s
  • Loading branch information
alanpaxton authored and adamretter committed Dec 1, 2024
1 parent 0ed20bc commit b903c07
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion exist-core/src/main/java/org/exist/dom/persistent/NodeProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Properties;

/**
Expand Down Expand Up @@ -112,6 +113,11 @@ public class NodeProxy implements NodeSet, NodeValue, NodeHandle, DocumentSet, C

private final Expression expression;

/**
* Used to cache the result of {@link #atomize()}.
*/
@Nullable private AtomicValue atomized = null;

/**
* Creates a new <code>NodeProxy</code> instance.
*
Expand Down Expand Up @@ -758,7 +764,10 @@ public AtomicValue convertTo(final int requiredType) throws XPathException {

@Override
public AtomicValue atomize() throws XPathException {
return new UntypedAtomicValue(getNodeValue());
if (atomized == null) {
atomized = new UntypedAtomicValue(getNodeValue());
}
return atomized;
}

@Override
Expand Down

0 comments on commit b903c07

Please sign in to comment.