Skip to content

Commit fefa17b

Browse files
committed
[bugfix] Address code-review issues found by Patrick Reinhart
1 parent 1e91318 commit fefa17b

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

exist-core/src/main/java/org/exist/dom/persistent/VirtualNodeSet.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ public boolean containsReference(final Item item) {
120120
}
121121

122122
final NodeProxy firstParent = getFirstParent((NodeProxy) item, null, axis == Constants.SELF_AXIS, 0);
123-
if (firstParent == item) {
124-
return true;
125-
}
126-
return false;
123+
return firstParent == item;
127124
}
128125

129126
@Override
@@ -133,10 +130,7 @@ public boolean contains(final Item item) {
133130
}
134131

135132
final NodeProxy firstParent = getFirstParent((NodeProxy) item, null, axis == Constants.SELF_AXIS, 0);
136-
if (firstParent.equals(item)) {
137-
return true;
138-
}
139-
return false;
133+
return firstParent.equals(item);
140134
}
141135

142136
public void setInPredicate(final boolean predicate) {

exist-core/src/main/java/org/exist/xquery/functions/array/ArrayType.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,9 @@ public static Sequence flatten(Sequence input) throws XPathException {
386386
public boolean containsReference(final Item item) {
387387
for (int i = 0; i < vector.length(); i++) {
388388
final Sequence value = vector.nth(i);
389-
if (value == item) {
389+
if (value == item || value.containsReference(item)) {
390390
return true;
391391
}
392-
return value.containsReference(item);
393392
}
394393
return false;
395394
}
@@ -398,10 +397,9 @@ public boolean containsReference(final Item item) {
398397
public boolean contains(final Item item) {
399398
for (int i = 0; i < vector.length(); i++) {
400399
final Sequence value = vector.nth(i);
401-
if (value.equals(item)) {
400+
if (value.equals(item) || value.contains(item)) {
402401
return true;
403402
}
404-
return value.contains(item);
405403
}
406404
return false;
407405
}

exist-core/src/main/java/org/exist/xquery/functions/map/MapType.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ public boolean contains(AtomicValue key) {
220220
public boolean containsReference(final Item item) {
221221
for (final Iterator<Sequence> it = map.values().iterator(); it.hasNext();) {
222222
final Sequence value = it.next();
223-
return value == item;
223+
if (value == item) {
224+
return true;
225+
}
224226
}
225227
return false;
226228
}
@@ -229,7 +231,9 @@ public boolean containsReference(final Item item) {
229231
public boolean contains(final Item item) {
230232
for (final Iterator<Sequence> it = map.values().iterator(); it.hasNext();) {
231233
final Sequence value = it.next();
232-
return value.equals(item);
234+
if (value.equals(item)) {
235+
return true;
236+
}
233237
}
234238
return false;
235239
}

0 commit comments

Comments
 (0)