Skip to content

Commit

Permalink
Merge pull request #1671 from mduesterhoeft/bugfix/map-traverse-perfo…
Browse files Browse the repository at this point in the history
…rmance

use a Vector as accumulator of map.traverse (#1633)
  • Loading branch information
danieldietrich authored Nov 11, 2016
2 parents b9f2263 + 662cdd7 commit a73d49f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion javaslang/src/main/java/javaslang/collection/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ default <U> U transform(Function<? super Map<K, V>, ? extends U> f) {

default <U> Seq<U> traverse(BiFunction<K, V, ? extends U> mapper) {
Objects.requireNonNull(mapper, "mapper is null");
return foldLeft(List.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
return foldLeft(Vector.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
}

default Tuple2<Seq<K>, Seq<V>> unzip() {
Expand Down
2 changes: 1 addition & 1 deletion javaslang/src/main/java/javaslang/collection/Multimap.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ default <U> U transform(Function<? super Multimap<K, V>, ? extends U> f) {

default <U> Seq<U> traverse(BiFunction<K, V, ? extends U> mapper) {
Objects.requireNonNull(mapper, "mapper is null");
return foldLeft(List.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
return foldLeft(Vector.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
}

default <T1, T2> Tuple2<Seq<T1>, Seq<T2>> unzip(BiFunction<? super K, ? super V, Tuple2<? extends T1, ? extends T2>> unzipper) {
Expand Down

0 comments on commit a73d49f

Please sign in to comment.