This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 54e6f1a Tweak `intersect` and `minus`
54e6f1a is described below
commit 54e6f1a547521479ca8e646ea13d1c4b25a0071d
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Nov 21 22:00:51 2020 +0800
Tweak `intersect` and `minus`
---
.../provider/collection/runtime/QueryableCollection.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git
a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
index 5b356e3..057239e 100644
---
a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
+++
b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
@@ -178,14 +178,26 @@ class QueryableCollection<T> implements Queryable<T>,
Serializable {
@Override
public Queryable<T> intersect(Queryable<? extends T> queryable) {
- Stream<T> stream = this.stream().filter(a ->
queryable.stream().anyMatch(b -> b.equals(a))).distinct();
+ Stream<T> stream = this.stream().filter(a -> {
+ if (queryable instanceof QueryableCollection) {
+ ((QueryableCollection) queryable).makeReusable();
+ }
+
+ return queryable.stream().anyMatch(b -> b.equals(a));
+ }).distinct();
return from(stream);
}
@Override
public Queryable<T> minus(Queryable<? extends T> queryable) {
- Stream<T> stream = this.stream().filter(a ->
queryable.stream().noneMatch(b -> b.equals(a))).distinct();
+ Stream<T> stream = this.stream().filter(a -> {
+ if (queryable instanceof QueryableCollection) {
+ ((QueryableCollection) queryable).makeReusable();
+ }
+
+ return queryable.stream().noneMatch(b -> b.equals(a));
+ }).distinct();
return from(stream);
}