fn:data() perfomance improvement!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

fn:data() perfomance improvement!

Евгений-8
Hello All, one more! :)

In current eXist CVS function "fn:data" not depend from context

Example:
<a>a<b>b</b></a>

"data(/a/b)" and "a/data(b)" is equal but "a/data(b)" slower


Patch see in attachment


Evgeny [hidden email]




Index: eXist-1.0/src/org/exist/xquery/functions/FunDistinctValues.java
===================================================================
RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunDistinctValues.java,v
retrieving revision 1.7
diff -u -r1.7 FunDistinctValues.java
--- eXist-1.0/src/org/exist/xquery/functions/FunDistinctValues.java 3 Oct 2004 20:49:21 -0000 1.7
+++ eXist-1.0/src/org/exist/xquery/functions/FunDistinctValues.java 13 Oct 2005 09:16:01 -0000
@@ -53,7 +53,7 @@
  new FunctionSignature(
  new QName("distinct-values", Module.BUILTIN_FUNCTION_NS),
  new SequenceType[] { new SequenceType(Type.ATOMIC, Cardinality.ZERO_OR_MORE)},
- new SequenceType(Type.ATOMIC, Cardinality.ONE));
+ new SequenceType(Type.ATOMIC, Cardinality.ZERO_OR_MORE));
 
  public FunDistinctValues(XQueryContext context) {
  super(context, signature);
@@ -90,10 +90,8 @@
  AtomicValue value;
  for (SequenceIterator i = values.iterate(); i.hasNext();) {
  value = (AtomicValue) i.nextItem();
- if (!set.contains(value)) {
- set.add(value);
+ if (set.add(value))
  result.add(value);
- }
  }
 // LOG.debug(
 // "distinct-values found "