Skip to content

Commit

Permalink
Fixed: Performance regression on Faker.Util.pick/1 (#221)
Browse files Browse the repository at this point in the history
Removed `Enum.to_list/1` call since `Enum.at/2` works fine with any enum.

Fixes #213 and fixes #219.
  • Loading branch information
aptinio authored and Igor Kapkov committed Nov 21, 2018
1 parent 9339bb4 commit 85a6ce4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format.

### Fixed

* `Faker.Util.pick/1` performance regression [[@aptinio][]]

### Security

## 0.11.1
Expand Down
4 changes: 1 addition & 3 deletions lib/faker/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ defmodule Faker.Util do
end

def pick(enum) do
enum
|> Enum.to_list()
|> Enum.at(Faker.random_between(0, Enum.count(enum) - 1))
Enum.at(enum, Faker.random_between(0, Enum.count(enum) - 1))
end

@doc """
Expand Down

0 comments on commit 85a6ce4

Please sign in to comment.