You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/07/21 01:02:00 UTC
[jira] [Updated] (GROOVY-10696) The DGM removeAll variants which take a closure can be refactored to use removeIf for better efficiency
[ https://issues.apache.org/jira/browse/GROOVY-10696?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-10696:
-------------------------------
Description:
We'd want all of the normal variations to work unchanged:
{code}
def list = ['a', 'b']
list.removeAll { it == 'b' }
assert list == ['a']
def m1 = [a:1, b:2]
m1.removeAll { k,v -> k == 'b' }
assert m1 == [a:1]
def m2 = [a:1, b:2]
m2.removeAll { k,v -> v == 1 }
assert m2 == [b:2]
def m3 = [a:1, b:2]
m3.removeAll { e -> e.key == 'b' }
assert m3 == [a:1]
{code}
was:
We'd want all of the normal variations to work unchanged:
{code}
def list = ['a', 'b']
list.removeAll { it == 'b' }
assert list == ['a']
def m1 = [a:1, b:2]
m1.removeAll { k,v -> k == 'b' }
assert m1 == [a:1]
def m2 = [a:1, b:2]
m2.removeAll { k,v -> v == 1 }
assert m2 == [b:2]
def m3 = [a:1, b:2]
m3.removeAll { e -> e.key == 'b' }
assert m3 == [a:1]
{code}
> The DGM removeAll variants which take a closure can be refactored to use removeIf for better efficiency
> -------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-10696
> URL: https://issues.apache.org/jira/browse/GROOVY-10696
> Project: Groovy
> Issue Type: Improvement
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
> We'd want all of the normal variations to work unchanged:
> {code}
> def list = ['a', 'b']
> list.removeAll { it == 'b' }
> assert list == ['a']
> def m1 = [a:1, b:2]
> m1.removeAll { k,v -> k == 'b' }
> assert m1 == [a:1]
> def m2 = [a:1, b:2]
> m2.removeAll { k,v -> v == 1 }
> assert m2 == [b:2]
> def m3 = [a:1, b:2]
> m3.removeAll { e -> e.key == 'b' }
> assert m3 == [a:1]
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)