Skip to content

Commit

Permalink
Optimize collect methods for primitive Immutable Singleton Bags, Sets…
Browse files Browse the repository at this point in the history
… and Lists.

Signed-off-by: Donald Raab <Donald.Raab@bnymellon.com>
  • Loading branch information
donraab committed Jun 30, 2020
1 parent 81bb243 commit 807eafc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Expand Up @@ -35,8 +35,8 @@ import org.eclipse.collections.api.block.procedure.primitive.<name>Procedure;
import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.list.primitive.Mutable<name>List;
import org.eclipse.collections.api.set.primitive.Mutable<name>Set;
import org.eclipse.collections.impl.bag.mutable.HashBag;
import org.eclipse.collections.impl.bag.mutable.primitive.<name>HashBag;
import org.eclipse.collections.impl.factory.Bags;
import org.eclipse.collections.impl.factory.Lists;
import org.eclipse.collections.impl.factory.primitive.<name>Bags;
import org.eclipse.collections.impl.iterator.Unmodifiable<name>Iterator;
Expand Down Expand Up @@ -216,7 +216,7 @@ final class Immutable<name>SingletonBag implements Immutable<name>Bag, Serializa
@Override
public \<V> ImmutableBag\<V> collect(<name>ToObjectFunction\<? extends V> function)
{
return HashBag.newBagWith(function.valueOf(this.element1)).toImmutable();
return Bags.immutable.with(function.valueOf(this.element1));
}

@Override
Expand Down
Expand Up @@ -43,7 +43,6 @@ import org.eclipse.collections.impl.factory.primitive.<name>Lists;
import org.eclipse.collections.impl.iterator.Unmodifiable<name>Iterator;
import org.eclipse.collections.impl.lazy.primitive.Lazy<name>IterableAdapter;
import org.eclipse.collections.impl.lazy.primitive.Reverse<name>Iterable;
import org.eclipse.collections.impl.list.mutable.FastList;
import org.eclipse.collections.impl.list.mutable.primitive.<name>ArrayList;
import org.eclipse.collections.impl.set.mutable.primitive.<name>HashSet;
import org.eclipse.collections.impl.utility.Iterate;
Expand Down Expand Up @@ -175,7 +174,7 @@ final class Immutable<name>SingletonList implements Immutable<name>List, Seriali
@Override
public \<V> ImmutableList\<V> collect(<name>ToObjectFunction\<? extends V> function)
{
return FastList.newListWith(function.valueOf(this.element1)).toImmutable();
return Lists.immutable.with(function.valueOf(this.element1));
}

<(arithmeticMethods.(type))(name, type)>
Expand Down
Expand Up @@ -38,8 +38,8 @@ import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.list.primitive.Mutable<name>List;
import org.eclipse.collections.impl.bag.mutable.primitive.<name>HashBag;
import org.eclipse.collections.impl.factory.Lists;
import org.eclipse.collections.impl.factory.Sets;
import org.eclipse.collections.impl.iterator.Unmodifiable<name>Iterator;
import org.eclipse.collections.impl.set.mutable.UnifiedSet;
import org.eclipse.collections.impl.set.mutable.primitive.<name>HashSet;
import org.eclipse.collections.impl.factory.primitive.<name>Sets;
import org.eclipse.collections.impl.lazy.primitive.Lazy<name>IterableAdapter;
Expand Down Expand Up @@ -168,7 +168,7 @@ final class Immutable<name>SingletonSet implements Immutable<name>Set, Serializa
@Override
public \<V> ImmutableSet\<V> collect(<name>ToObjectFunction\<? extends V> function)
{
return UnifiedSet.\<V>newSetWith(function.valueOf(this.element)).toImmutable();
return Sets.immutable.with(function.valueOf(this.element));
}

@Override
Expand Down

0 comments on commit 807eafc

Please sign in to comment.